开发者

MS Entity Framework 4.1 - Maintain data across restructuring

I am using the Code First approach to manage the EF. However开发者_运维百科 all the examples I have seen don't seem to allow you to use EF where you are able to make changes to the DB schema and preserve your data.

So say I have an entity/object of:

public class Person
   int Id;
   string NickName;

and I now add Age so:

public class Person
   int Id;
   string NickName; 
   int Age;

how can I preserve the data that may already be in the database for "Person"?


Dont call the System.Data.Entity.Database.SetInitializer().

Or call System.Data.Entity.Database.SetInitializer() with CreateDatabaseIfNotExists().

Calling with DropCreateDatabaseAlways or DropCreateDatabaseIfModelChanges will always drop Db.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜