EdB
EdB

Reputation: 449

EF Code First, Where is the database specified?

I have just created a test SQLServer Express DB when experimenting with EF Code First. The DB has been created correctly and all works. However I cannot see where the connectionstring is for this DB. I expected to find it in Web.config, but not so.

Thanks in advance,

Ed

Upvotes: 1

Views: 56

Answers (1)

Kyle Trauberman
Kyle Trauberman

Reputation: 25694

EF defaults to ./sqlexpress for the server URI. To change this, add a connectionstring with the name set to the same name as your DBContext class

For example, assuming your DbContext class is called "MyDbContext":

<add name="MyDbContext" connectionString="connectionStringHere" providerName="System.Data.SqlClient" />

Upvotes: 1

Related Questions