开发者

How do I add a column to a table (schema upgrade) and have it map to an EF code first object

开发者 https://www.devze.com 2023-03-31 10:11 出处:网络
I have a database that I created for a site using Entity Framework 4.1 code first. I need to add a simple property to one of my entity classes, and add a corresponding (possibly nullable) column to th

I have a database that I created for a site using Entity Framework 4.1 code first. I need to add a simple property to one of my entity classes, and add a corresponding (possibly nullable) column to the database without losing any of the data in the database.

I think I can take down the site, alter the database to add the column, and redeploy website with an updated entity class, but I'm not sure that's the best way to do this schema u开发者_开发技巧pgrade.

Is there a standard (or just better) way of doing a schema upgrade on a DB that was created using code first?


Entity Framework Code First has a new feature in preview called Code First Migrations, which does simple schema upgrades.

You can check it out here http://blogs.msdn.com/b/adonet/archive/2011/07/27/code-first-migrations-walkthrough-of-august-2011-ctp.aspx

0

精彩评论

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