EF CTP5 自动创建表 SQL Server 2005
我一直在使用 EF 4 CTP5 并关注 scottgu 博客文章: http://weblogs.asp.net/scottgu/archive/2010/07/16/code-first-development-with-entity-framework-4.aspx
基本上,如果表格丢失,我希望模型为我生成表格。
就我而言,它抱怨有一个无效的数据库对象,那是因为我还没有表。我使用的是 SQL Server 2005,而博客提到了 sqlexpress 或 ce。
我想要创建表的模式,该功能仅适用于 sqlexpress 和 CE 吗?
提前致谢
I've been using EF 4 CTP5 and was following scottgu blog post: http://weblogs.asp.net/scottgu/archive/2010/07/16/code-first-development-with-entity-framework-4.aspx
Basically I would like the model to generate the table for me if it is missing.
In my case it is complaining that there is an invalid database object, that's because I don't have a table yet. I'm using SQL Server 2005, whereas the blog mentions sql express or ce.
I would like the mode to create the table, is that feature only for sql express and CE?
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
“基本上,如果表格丢失,我希望模型为我生成表格”
目前,使用 CTP5 不支持这种情况,但在(不久的)将来应该可以做到这样的事情: http://blogs.msdn.com/ b/efdesign/archive/2010/10/22/code-first-database-evolution-aka-migrations.aspx
目前仅支持以下2种初始化策略:
或者
还需要注意的是,EF创建了整个数据库,而不仅仅是表,因此您不必自己创建数据库。
"Basically I would like the model to generate the table for me if it is missing"
That scenario is currently not supported using CTP5 however it should be possible to do such a thing in the (near) future: http://blogs.msdn.com/b/efdesign/archive/2010/10/22/code-first-database-evolution-aka-migrations.aspx
Currently only the following 2 initialization strategies are supported:
or
It should also be noted that EF creates the whole database, not just the tables, so you don't have to create the database yourself.