Multiple Projects using ADO.NET Entity Connection String

ado.net ado.net-entity-data-model entity-framework linq-to-entities

Question

The ADo.NET Entity model is hosted by the DataModel in a multi-tier project I'm working on, and validation is handled by the DataAccess layer.

But each time I encounter a problem like this

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

I experimented with connection strings

<add name="SalesEntities" connectionString="metadata=res://*/SalesEntities.csdl|res://*/SalesEntities.ssdl|res://*/SalesEntities.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=.;Initial Catalog=Phoenix;Integrated Security=True;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" />

and

<add name="SalesEntities" connectionString="metadata=.\SalesEntities.csdl|.\SalesEntities.ssdl|.\SalesEntities.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=.;Initial Catalog=Phoenix;Integrated Security=True;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" />

attempted several permutations to refer to the called project directory's root directory, but to no avail.

Any assistance is much appreciated. As usual, many thanks:).

1
27
7/11/2009 9:50:54 AM

Popular Answer

These connection strings must be included in each application's app.config file. The similar issue will arise if you have a DAL that you used to create the model and attempt to use the DAL in an EXE. The connection string is not known to the EXE.

I've discovered that adding an app.config to each project and just copying the connection string from the DAL I first produced the models in is the simplest method. Each will then have a duplicate of that connection string.

26
7/11/2009 10:03:19 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