开发者

Auto-generating database scheme with Code First EF4 and SQL 2008

Code First in Entity Framewor开发者_运维技巧k 4 does not seem to behave exactly the same while using SQL 2008 as if used with Express or CE. The database scheme is not auto-generated. Is there a way to force the creation of the tables or can T-SQL be generated somehow?


Not sure exactly what difference do you see between SQL 2008 and Express version. You can create the database by calling:

if (!context.Database.Exists())
{
  context.Database.Create();
}

Where context is instance of your DbContext. Also make sure that your connection string is configured. You can add connection string with the same name as your context class.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜