Reputation: 1
I have an application in ASP web forms. I working on migrating this web form application to .net core 3.0. I am using database first approach as I have perfect tables structure, many store procedures and too much data. Today I add some new columns in data table 'Stock'. Columns name are:
I also add one new table 'Locations' in my database. Now the question is how can I update the DB context model class in my project for this two tables changes using database first approach in .net core.
Upvotes: 0
Views: 2032
Reputation: 842
Using the Package Manager Console
Scaffold-DbContext "your_connection_string" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models -Force
using CLI
dotnet ef dbcontext scaffold "your_connection_string" Microsoft.EntityFrameworkCore.SqlServer -o Models -f
if you want to re-scaffold the model after making schema changes, you can do so by specifying the -force option e.g.:
dotnet ef dbcontext scaffold "your_connection_string" Microsoft.EntityFrameworkCore.SqlServer -force
All of the class files will be overwritten, which means that any amendments that you might have made to them e.g. adding attributes or additional members, will be lost.
Upvotes: 5