Ryan
Ryan

Reputation: 5544

entity framework code first saves data somewhere, but don't know where

I just installed a fresh win7, VS, SQl server 2008 R2. I run the SaveChanges() method and the data is saved somewhere but I can't see any created database in Sql server 2008 manager. What should I do? I know that the data is saved because I can retrieve it.

Where has code first saved my data? how can I make it save date in Sql server 2008, or if the data is there shouldn't it appear in Databases node?

Upvotes: 1

Views: 316

Answers (1)

bricelam
bricelam

Reputation: 30435

By default, Code First connects to the SQL Express instance (Data Source=.\SQLEXPRESS). To have it save data in another insatnce (e.g. Data Source=(local)), change the connection string that you supply.

public MyContext()
    : base("Data Source=(local);Initial Catalog=MyDatabase;User ID=john;Password=doe;MultipleActiveResultSets=true")
{
} 

For the various ways of setting a connection string, check out this article.

Upvotes: 1

Related Questions