Search code examples
ef-code-firstconnection-stringentity-framework-ctp5

What is the Default Database for Entities Code-First without defined Connection String?


I have written a trivial Entities code-first WinForms application with one simple class and one database context class as all the tuturials describe it.

But I did not add a connection string in the app.config file.

Nevertheless, when I start the application, it can insert objects into the database and even show all objects already inserted.

I figure there must be some default database in SQL Server for that case but I cannot find out which instance and database name is used.


Solution

  • Database name is the same as the name on your DbContext class. By default it creates a database on the local machine Sql Server express installation. You should be able to see it in Sql Server Managment when you connect to your local SQLEXPRESS.

    If you spesify a connectionstring with the same name as youd DbContext it will use that instead.