Phil
Phil

Reputation: 3994

Entity Framework; updating DB from Model?

In mySql Workbench there's a possibility to "sync" the model with the DB and vice versa. Is there a function like this in EF? I've added som entities and I'd like it to get reflected in the DB. Do I really have to regenerate the entire DB and loose data?

Thanks

Upvotes: 2

Views: 476

Answers (2)

Ruchika rana
Ruchika rana

Reputation: 21

if you are using the VS2010 then in Select your edmx designer ( designer showing tables) and right click it will show the update model option.

Upvotes: -1

Ian Mercer
Ian Mercer

Reputation: 39297

Sadly there is no easy way AFAIK to do this today.

One way to handle this is to generate the DDL and then cut and paste the new sections into SQL Server Management Studio and run them there. If you want to maintain scripts for each release of the database you'll need to take an approach like this too.

See also: Database migrations for Entity Framework 4

PS The EF Power Pack: http://msdn.microsoft.com/en-us/data/ff830362.aspx may help. It says "The second useful feature related to model-first the ability to update an existing database and synchronize the model with it. This allows you to make changes to the model that can be deployed to the database without data loss."

Upvotes: 2

Related Questions