Entity Framework Code First and Connection String Issue

Mike Flynn picture Mike Flynn · Aug 21, 2011 · Viewed 30.3k times · Source

I am getting this error when using Entity Framework 4.1 code first. I can not find any sources of what exactly to use.

Unable to load the specified metadata resource.

<add name="DataContext" connectionString="metadata=res://*/GrassrootsHoopsDataContext.csdl|res://*/GrassrootsHoopsDataContext.ssdl|res://*/GrassrootsHoopsDataContext.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=myserver.com;Initial Catalog=MyDataBase;Persist Security Info=True;User ID=username;Password=password&quot;" providerName="System.Data.EntityClient" />

Answer

Eranga picture Eranga · Aug 21, 2011

For EF Code First you can use ordinary connection string if you are using SQL Server.

<add name="DataContext" connectionString="Data Source=myserver.com;Initial Catalog=MyDataBase;Persist Security Info=True;User ID=username;Password=password"  providerName="System.Data.SqlClient" />