I am learning Code First development with a console application. In many of the examples, including Scott Gu’s post, they suggest using Sql Server CE 4.0 and set it up so that the code creates the database automagically.
I am doing a console app and would like to examine the database with a management tool, such as management studio or linqpad. What is the location of the sdf file that is created?
I created an App.Config and placed the following in it:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<add
name="NerdDinners"
providerName="System.Data.SqlServerCe.4.0"
connectionString="Data Source =|DataDirectory|NerdDinners.sdf"/>
</connectionStrings>
</configuration>
However, NerdDinner is not created, and instead a database in SQLExpress is created. I seem to have confused some things here.
It depends upon the connection string you have set in app.config file. In most cases (
DataDirectory) database file will be created atDebug\binfolder (winform app).Sample app: (Add the ref of
System.ComponentModel.DataAnnotations.dllandEntityFramework.dll)app.config (The name of connection string must match the name of
Contextclass)Add a record,