Is there a way to prevent Entity Framework Code-First from deleting my database diagrams when it is re-building my database?
Asked
Active
Viewed 335 times
3
-
Did you map the system tables? – Craig Stuntz Aug 23 '11 at 02:49
-
Not yet =) Are you saying that doing a code-first mapping of sysdiagrams is the only way? – anon Aug 23 '11 at 02:52
-
No, there's always the DB generation power pack. Or put your diagrams in a different DB? – Craig Stuntz Aug 23 '11 at 02:54
-
Well, I guess I'd prefer to keep my diagrams in my database. Can you point out an article or provide some basic instructions on how the power pack can help with this? – anon Aug 23 '11 at 02:59
-
The power pack lets you not drop and recreate the DB when changing metadata. Google it. – Craig Stuntz Aug 23 '11 at 10:33
1 Answers
1
Without using DropCreateDatabaseIfModelChanges
to create your database you can use SQL Migrations
http://www.hanselman.com/blog/EntityFrameworkCodeFirstMigrationsAlphaNuGetPackageOfTheWeek10.aspx. It won't drop the database and will generate alter commands (Incremental database development) . So you can keep your diagram and existing data.

Jayantha Lal Sirisena
- 21,216
- 11
- 71
- 92