Entity Framework, Code First: where is the database?

Shows where Entity Framework 5 Code First creates its automatic LocalDB database in Visual Studio 2012 and how to access it through SQL Server Object Explorer.

With Entity Framework 5 in Visual Studio 2012 the code first feature could let you come to the question “Where is the automatically created database located?”

I run in the question after changing the model which throws during the next run this error:

“The model backing the ‘MyContext’ context has changed since the database was created. Consider using Code First Migrations to update the database MSDN: Code First Migrations.”

Okay – clear I thought “delete the database”. But where is the database and what type is it???

In this constellation the frameworks generates a localDB.

You could access this database via SQL Server Object Explorer. For the first time you have to add this localDB. The server name is (localdb)\v11.0:

image

And so we could browse through the content of this database. It got the same name like the context class.

image