Entity Framework: Connecting to a mdf user database file via localDB during script execution

Posted by Marko Apfel on Geeks with Blogs See other posts from Geeks with Blogs or by Marko Apfel
Published on Sun, 21 Oct 2012 10:35:00 GMT Indexed on 2012/10/22 11:02 UTC
Read the original article Hit count: 284

Filed under:

Problem

If you run the “Generate database from model” wizard and execute the generated script the destination database could be the wrong one (for instance master of the SQL Server).

Solution

To use an own mdf attachable user database some connection information must specified during script execution.

Execute your script opens the dialog “Connect to Server”.

image

Press “Options” and go to the second tab “Connection Properties”.

Select “Browse server” in the “Connect to database” dropdown box:

image

Confirm the information dialog with “Yes”.

In the following dialog you could choose your user database.

image

Now the schema is created in the user database.

© Geeks with Blogs or respective owner