我创建了一个测试项目来测试我的查询,一切都很顺利,除了当我尝试测试使用 Entity Connection
的方法时,出现以下异常:
The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid.
我在启动项目TestQuery的app.config文件中的连接字符串如下:
<connectionStrings>
<add name="DataLayer.Context" connectionString="Data Source=.;Initial Catalog=TestQ;Integrated Security=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
所有使用linq to entity的方法都能很好地工作并获取数据,除了这个方法?
objectContext.CreateQuery
时会自动获取)。你没有执行本地SQL。而且Entity Command 无法执行本地SQL。 - Gert Arnold