Sco*_*ies 3 entity-framework-4
我正在阅读有关Entity Framework 4.0的文章,其中说明了以下内容:
"The model's context menu has an option to 'Generate Database Script from
Model'. When you select this option you'll find that you do need to point
to an existing database. The script won't create the database itself,
just the schema, which means that you'll need to create the database yourself
in advance."
Run Code Online (Sandbox Code Playgroud)
如果EF 4.0设计器生成SQL以破坏现有数据库,为什么首先需要现有数据库?
谢谢,
斯科特
它会为您生成表/索引等.您只需提供一个现有的空数据库.
否则你会遇到鸡和蛋的问题,因为你必须提供一个指向现有数据库的连接字符串,以便能够首先连接到数据库.
虽然可能有一些选项让EF生成数据库,但实际上可能不值得实施.只需在现有但空的数据库中填充EF.