I am facing a problem in a windows forms application (.net 4.0) using entity framework 5.
I have a DbContext instance as a class field in a form like this:
protected MascoteAquariumEF model = new MascoteAquariumEF("name=MascoteAquariumEF");
here is my connection string:
<connectionStrings>
<add name="MascoteAquariumEF"
connectionString="metadata=res://*/MascoteAquariumDBContext.csdl|res://*/MascoteAquariumDBContext.ssdl|res://*/MascoteAquariumDBContext.msl;provider=System.Data.SqlClient;provider connection string='data source=vm_visual_stdo\sqlexpress2008;initial catalog=MascoteAquarium;integrated security=True;multipleactiveresultsets=True;App=EntityFramework'"
providerName="System.Data.EntityClient" />
</connectionStrings>
And in the designer I am seeing this error:
The form don’t get really designed….but running the project its ok (no error)
The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid.
any idea??
Try to pass name value only:
Also I think it’s better to check if form in designer before instantiating your context: