views:

48

answers:

2

Hi,

I am reading an article about Entity Framework 4.0 that states the following:

"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."

If the EF 4.0 designer generates SQL to clobber the existing database, why is an existing database first required ?

Thanks,

Scott

+3  A: 

It will generate the tables/indexes etc. for you. You just need to supply an existing , empty, database.

You'd run in to a chicken and egg problem otherwise, as you'd have to e.g. provide a connection string pointing to an existing database to be able to connect to a database in the first place.

And while there might have been some options to have EF generate the database as well, it's likely not worth the implementation trouble. Just poiint EF at an existing but empty database.

leeeroy
+1  A: 

This link might shed some light.