gpt4 book ai didi

wcf - 无法使用 Entity Framework 查找或加载 Npgsql

转载 作者:行者123 更新时间:2023-12-02 02:03:41 24 4
gpt4 key购买 nike

我完全迷失了。在Visual Studio 2015中,我创建了一个WCF库服务项目并定义了服务和服务接口(interface)。

EntityFramework、EntityFramework.SqlServer、EntityFramework6.Npgsql 和 Npgsql 是通过 NuGet 控制台安装的:

  • PM> 安装包 EntityFramework6.Npgsql -版本 3.0.5

将库服务设置为启动然后正确启动调试(f5)阅读可用的程序。然而,在测试任何程序后WcfSvcHost,我收到以下错误:

The ADO.NET provider with invariant name 'Npgsql' is either not registered in the machine or application config file, or could not be loaded. See the inner exception for details.

我做错了什么?

这是 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=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
</configSections>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" />
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host's
app.config file. System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<services>
<service name="NovaMedicalService.MedicalService">
<endpoint address="" binding="basicHttpBinding" contract="NovaMedicalService.IMedicalService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733/Design_Time_Addresses/NovaMedicalService/MedicalService/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information,
set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="True" httpsGetEnabled="True" />
<!-- To receive exception details in faults for debugging purposes,
set the value below to true. Set to false before deployment
to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v12.0" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
<provider invariantName="Npgsql" type="Npgsql.NpgsqlServices, EntityFramework6.Npgsql" />
</providers>
</entityFramework>
<connectionStrings>
<add name="chaosEntities" connectionString="metadata=res://*/ChaosModel.csdl|res://*/ChaosModel.ssdl|res://*/ChaosModel.msl;provider=Npgsql;provider connection string=&quot;Database=chaos;Host=localhost;Password=yuyuyu;Username=ooosos&quot;" providerName="System.Data.EntityClient" />
</connectionStrings>
</configuration>

有人可以帮忙吗?我完全迷失了。

TIA

最佳答案

问题已解决。我忘记添加:

<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>

(参见 Visual Studio Support (DDEX)

关于wcf - 无法使用 Entity Framework 查找或加载 Npgsql,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35425249/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com