reach4thelasers
reach4thelasers

Reputation: 26899

EntityFramework Data Initialization

I'm using Entity Framework Code First. The database initialization works great for creating the database and tables.

I was wondering if there's a way to make the process less destructive... rather than issuing DROP / CREATE statements when the schema changes, is there any way (via an off-the-shelf Initializer, or otherwise) to issue ALTER statements to update my schema?

Upvotes: 2

Views: 462

Answers (2)

Muneeb
Muneeb

Reputation: 1

I think this might help: http://www.entityframeworktutorial.net/code-first/database-initialization-strategy-in-code-first.aspx There is an example of using custom method to initialize data.

Upvotes: 0

Stephen Newman
Stephen Newman

Reputation: 1977

You should look into Code First Data Migrations, I've not used it myself but I believe it's what you are looking for.

http://blogs.msdn.com/b/adonet/archive/2012/02/09/ef-4-3-released.aspx

To help those that come along later, you should be able to follow these instructions to get it all setup : http://blogs.msdn.com/b/adonet/archive/2012/02/09/ef-4-3-code-based-migrations-walkthrough.aspx

Upvotes: 3

Related Questions