Evgeny
Evgeny

Reputation: 3322

Update Database from Model (when model changed)?

I'm developing an application (for my education, not commercial) using MVC3 and Model First approach.

I created a model and generated the SQL CE 4 database from it.

Next, I may need to change my model - i.e. add a column to a table, which is not a primary or foreign key column.

I only see an option "Generate Database From Model", which will drop my database and create a new one.

Is there a way to "Update Database From Model", which will preserve the database and just add the new columns, populating them with some default values or nulls?

A similar question Update database from model - Entity Framework was asked last year and suggested that the solution may become available in the future - but did anything change since then?

Upvotes: 2

Views: 2383

Answers (3)

ap_waaijenberg
ap_waaijenberg

Reputation: 31

Updating the answer from @torm with what I've found in the NuGet page

The owner has unlisted this package. This could mean that the package is deprecated or shouldn't be used anymore.

Upvotes: 0

Ashok Padmanabhan
Ashok Padmanabhan

Reputation: 2120

also see this msdn article the page has a couple of links for walkthroughs on using the migrations tools

Upvotes: 1

Paweł Staniec
Paweł Staniec

Reputation: 3181

There is a package that takes care of that. It's EntityFramework.Migrations in NuGet repository. There's a good read for that : http://www.hanselman.com/blog/EntityFrameworkCodeFirstMigrationsAlphaNuGetPackageOfTheWeek10.aspx

Package itself is on : http://nuget.org/List/Packages/EntityFramework.Migrations

It was also presented by Scott Hanselman on MIX 11 http://channel9.msdn.com/Events/MIX/MIX11/FRM02 (really awesome video showing usage of scaffolding, elmah, glimpse and more )

Upvotes: 3

Related Questions