Angular Dev
Angular Dev

Reputation: 19

How to update models and DBContext class in Entity Framework core (if database created first)

As the title indicates I Have an SQL server database already made and I excuted the following command to generate DBContext class and the model:

Scaffold-DbContext "connectionstring" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models

later on a table has been added through SQL server( Not through a model migration command)

is there a way to generate the related model for it and update the dbContext ?

if i re-excute the command above I would get Build Failed

Upvotes: 0

Views: 1489

Answers (2)

Sudharsan R
Sudharsan R

Reputation: 19

you want to update model and context if it already exits then you can use update wizard to update model by clicking on edmx diagram , then right click on empty white space and click update model from db

Upvotes: 0

ErikEJ
ErikEJ

Reputation: 41749

Use

-Force

Or have a look at EF Core Power Tools.

Upvotes: 1

Related Questions