Richard
Richard

Reputation: 1106

Can’t find the new Code First Entity Framework Database

Basically I am using the Entity Framework Code First technique. The code I wrote works. However, I can’t find the newly created database in SQL Server Management Studio. Where is it? What IDE should I be using to see the newly created database and tables. I ran the following code with no problem: IsoLocationContext db = new IsoLocationContext();

   Address address = new Address();

   address.TrackingNumber = "123";

   db.Addresses.Add(address);
   db.SaveChanges();

However, I can’t seem to find the database and tables. I did tried to refresh the list of databases.
I then added the following the line just to make sure the data was actually going to the database.

   IList<Address> addresses = db.Addresses.ToList();

The above processing worked as well. I also stopped and started the server and rebooted the whole machine. Just to make sure the data wasn’t being stored in memory. Everything worked as expected. I also ran the Profiler against the server while I was running the app and I saw no entries in the Trace.

Please tell me, what I am missing. This is driving me crazy.

Also I am using SQL Server 2008 R2 Developer / Client version.

Upvotes: 7

Views: 3499

Answers (1)

John Gibb
John Gibb

Reputation: 10773

Try looking at your connection string like this:

 ((IObjectContextAdapter)db).ObjectContext.Connection.ConnectionString

Upvotes: 11

Related Questions