0

所以我在这个问题上苦苦挣扎了 4 个多小时,我不知道再去哪里看。我为绝对初学者遵循本教程ADO.NET Entity Framework- [参见教程][1] [1]:http: //msdn.microsoft.com/en-us/data/jj193542 我正在使用Microsoft SQL Server 2012并且我正在使用这个App.Config文件我的项目 :

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="Data Source=sqlserver2012; Integrated Security=True; MultipleActiveResultSets=True" />
      </parameters>
    </defaultConnectionFactory>
  </entityFramework>
</configuration>

但是我不断收到错误,当我使用此代码时,错误是:**An error occurred while getting provider information from the database. This can be caused by Entity Framework using an incorrect connection string.**

我完全是新手,ADO.NET Entity Framework但正如我所见,问题可能出在defaultConnectionFactory配置中。但无论如何,我不知道如何继续以及如何解决这个问题。

4

1 回答 1

0

如果您实际上在本地主机上有名为 sqlserver2012 的 SQL Server 实例 zour connectionString 应该如下所示

<parameter value="Data Source=localhost\sqlserver2012; Integrated Security=True; MultipleActiveResultSets=True" />

干杯,T。

于 2013-02-12T15:08:11.987 回答