8

I have the following connection string:

  connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-WebUx-20121229234926;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-WebUx-20121229234926.mdf" 
  providerName="System.Data.SqlClient" />

I'm using Entity Framework and now I would like to use Code Fist to create a new database. Can someone explain what is meant by:

aspnet-WebUx-20121229234926

Could I just create any name here as long as it is the same as the name of the file that holds the data?

1 Answers1

6

Initial Catalog is the name of the database to be used by the connection string, which is located on the server that was specified in the Data Source part of the connection string.

If there are multiple databases on the server that you have permissions to use in Data Source then you have to specify the Initial Catalog to help it distinguish between which one you want.

If however, there is only one database on the server specified in the Data Source, then you don't need to specify the Initial Catalog.

Personally, I would say always specify both, as adding another database onto that server that you have access to could break your application if you don't use Initial Catalog.

Mathew Thompson
  • 55,877
  • 15
  • 127
  • 148