I create a Test Project to test my queries , every thing goes okay except when i try to test a method which use Entity Connection
,I get the following exception :
The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid.
My connection string in app.config
in the TestQuery
Project which is my startup project is:
<connectionStrings>
<add name="DataLayer.Context" connectionString="Data Source=.;Initial Catalog=TestQ;Integrated Security=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
All the methods which use linq to entity works just fine and brings the data except this one ?
This is not the way to execute an Entity SQL command. You should do this instead:
// If you have a DbContext instance:
var objectContext = ((IObjectContextAdapter)dbContext).ObjectContext;
var query = objectContext.CreateQuery<Crop>(eSQL);
var result = query.ToList();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With