Question

I'm using DropCreateDatabaseIfModelChanges DB initializer class in Entity-framework-4.2. Problem is it creates a new database and old data is lost. I used seed method of this class to enter some new values. But in that way I cannot preserve my old data. Does anyone know a way to drop and create a DB when model changes, without losing existing data?

Thank you.

Was it helpful?

Solution

No it is not possible with built-in database initializers and writing custom initializer preserving data would be very complex task. As alternative you can use Code First Migrations instead of initializers. Migrations allows incremental development of your database.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top