2016-02-16 5 views
4

Я полностью потерян. В Visual Studio 2015 я создал проект службы библиотеки WCF и определил интерфейс службы и сервиса.Невозможно найти или загрузить Npgsql с Entity Framework

EntityFramework, EntityFramework.SqlServer, EntityFramework6.Npgsql и Npgsql был установлен с консолью NuGet:

  • PM> Install-Package EntityFramework6.Npgsql -Version 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

ответ

6

Проблема решена. Я забыл добавить:

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

Смежные вопросы