无法使用npgsql数据提供程序将asp.net应用程序连接到POSTGRESQL数据库

时间:2018-03-30 04:21:53

标签: postgresql asp.net-mvc-4 npgsql

我是使用C#的asp.net MVC的新手,我正在使用POSTGRESQL作为数据库。我在使用Npgsql从asp.net应用程序连接到localhost上的POSTGRESQL时遇到问题。我收到以下错误

The Entity Framework provider type 'Npgsql.NpgsqlServices, EntityFramework6.Npgsql' registered in the application config file for the ADO.NET provider with invariant name 'Npgsql' could not be loaded. Make sure that the assembly-qualified name is used and that the assembly is available to the running application.

我在web.config文件中的代码是

<connectionStrings>
    <add name="DefaultConnectionString" connectionString="server=localhost; port=5432 ;user-id=postgres ;password=postgres ;database=postgres " providerName="Npgsql" />
  </connectionStrings>

  <system.data>
    <DbProviderFactories>
      <remove invariant="Npgsql"/>
      <add name="Npgsql Data Provider" invariant="Npgsql" description=".Net Data Provider for PostgreSQL" type="Npgsql.NpgsqlFactory, Npgsql, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7" support="FF" />
   </DbProviderFactories>
  </system.data>

<entityFramework>
    <defaultConnectionFactory type="Npgsql.NpgsqlConnectionFactory, Npgsql" />
    <providers>
      <provider invariantName="Npgsql" type="Npgsql.NpgsqlServices, EntityFramework6.Npgsql" />
    </providers>
  </entityFramework>

注意:我正在使用VS 2012,postgreSQL 9.6(pgadmin3)并安装了Entity framework 6.0.0版本包

0 个答案:

没有答案