EFCodeFirst and Connection String Name

Mar 2, 2011 at 6:12 AM

I think many would be using the EFCodeFirst to hook up your model to an existing database.

I played around with connecting to another copy of the MvcMusicStore Db. The one created by the MvcMusicStore-create.sql script, and in my setup placed as a SQL2008R2 Db on my SQL2008R2 Server instead of the local SQLExpress instance.

One lesson learned here, which perhaps warrants a paragraph in the PDF tutorial, is that:

By convention, the EFCodeFirst - when hooking up to an existing Db - is looking for a Connection String Name that is the same as the Model Context Class name.

What I experienced was that the solution would compile, and when trying to navigate to the Store, it would give you various cryptic error messages.

That's what you get for straying outside of the beaten template turorial path.

I guess many of us would have a tendency to do that, just to get kicked by lack of knowledge about the various conventions applied to the MVC development platform.

Regards

borge