0

I have an existing SQL Server database that populated with data via another app. I want to work with this database in a new project (ASP.NET Core web application).

I know I can add this database to my project by database-first way (write a command line in package manager console). But I don't know how I can work with this model that add data annotation to existing entity fields, or add new entity (table) to this model, so that data in main database doesn't get damaged and my changes that I do in my model, add and import to it (main database).

Can someone help me? Is there any way to do this? Does I need to use migrations? Or not?

3
  • As far as I know, if you used database first it will still create the model in your application. Then you could modify them and use migrations to modify the database in your new asp.net core application. Commented Mar 15, 2021 at 9:24
  • I tried this. but It didn't work. It started to recreate all existing table. Commented Mar 17, 2021 at 12:21
  • It based on your requirement about modifying the model class. If you modify the model class's existed class, it will recreate all existing table. Commented Mar 18, 2021 at 1:36

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.