Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Entity Framework Code First and Connection String Issue

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" /> 
like image 713
Mike Flynn Avatar asked Aug 21 '11 00:08

Mike Flynn


People also ask

How do I change the connection string in Entity Framework?

If you want to change the connection string go to the app. config and remove all the connection strings. Now go to the edmx, right click on the designer surface, select Update model from database, choose the connection string from the dropdown, Click next, Add or Refresh (select what you want) and finish.


1 Answers

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" /> 
like image 179
Eranga Avatar answered Oct 27 '22 15:10

Eranga