[HOWTO] Create LocalDB File (.mdf) manually in Visual Studio 2015

If you are using LocalDB and want to create an empty database you should perform the following steps.

  1. Go to Visual Studio Server Explorer | Data Connections
  2. Select Add Connection from the context menu
  3. Change Data Source to Microsoft SQL Server Database File (i.e. LocalDB)
  4. Set the Database file name by entering a database name and path that corresponds to the name in the web.config/app.config connectionstring.
    Replace |DataDirectory| with path to the place the database file should be created at (i.e. App_Data)
  5. Select Advanced and set the properties according to the following example connection string
    Data Source=(localdb)\v11.0; Initial Catalog=Arbitrary; Integrated Security=True; MultipleActiveResultSets=True; AttachDbFilename=C:\PATH\TO\Arbitrary.mdf
    

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: