3

我正在阅读一篇关于 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."

如果 EF 4.0 设计器生成 SQL 来破坏现有数据库,为什么首先需要现有数据库?

谢谢,

斯科特

4

1 回答 1

5

它将为您生成表/索引等。您只需要提供一个现有的空数据库。

否则,您会遇到先有鸡还是先有蛋的问题,因为您必须首先提供指向现有数据库的连接字符串才能连接到数据库。

虽然可能有一些选项可以让 EF 生成数据库,但它可能不值得执行麻烦。只需将 EF 指向现有但为空的数据库。

于 2010-03-02T18:07:34.740 回答