Starting at index 0, the given named connection is either not found or the format of the startup string does not adhere to the standard.

.net c# entity-framework

Question

What does this error mean?

Format of the initialization string does not conform to specification starting at index 0.

and also getting this error:

The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid.

I'm trying to use my EF model context in another project in Visual Studio. Having real trouble just getting my EF application off the ground. I instantiate the model context like so:

ctx = new VisitoriDataModel("VisitoriDataModel");

I have the connection string copied from the data layer project into all projects including the web.config and still no luck.

Also tried the following:

//model = new VisitoriDataModel(new EntityConnection("Name=VisitoriDataModel"));
//model = new VisitoriDataModel("Name=VisitoriDataModel");
//model = new VisitoriDataModel("VisitoriDataModel");
//model = new VisitoriDataModel();

ConnectionString is like so:

metadata=res://*/Context.VisitoriDataModel.csdl|res://*/Context.VisitoriDataModel.ssdl|res://*/Context.VisitoriDataModel.msl;provider=System.Data.SqlClient;provider connection string="data source=.\SQLEXPRESS;initial catalog=visitori;integrated security=True;multipleactiveresultsets=True;App=EntityFramework"
1
3
1/27/2014 5:00:33 PM

Accepted Answer

The connection string needs to go in the project that is being executed. If this is a website, that would be the web.config. Make sure it's correctly nested, and not inside another node like <system.web>, you should have:

<configuration>
  ...
  <connectionStrings>
    <add name="VisitoriDataModel" connectionString="metadata=res://*/Context.VisitoriDataModel.csdl|res://*/Context.VisitoriDataModel.ssdl|res://*/Context.VisitoriDataModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.\SQLEXPRESS;initial catalog=visitori;integrated security=True;multipleactiveresultsets=True;App=EntityFramework&quot;"
      providerName="System.Data.EntityClient" />
  </connectionStrings>
  ...
</configuration>

Also note that the "'s around the provider connection string inside the entity connection string need to be escaped as &quot;

6
7/29/2011 2:31:22 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow