2015-11-16 71 views
0

我有兩個項目,其中一個包含實體模型並充當DAL,另一個使用該模型並實現應用程序邏輯。訪問單獨項目中的實體模型時出錯

該模型是一個類庫項目,該應用程序是一個Windows窗體項目。

具有項目下面的app.config文件,並在窗體項目已經引用System.Data.Entity的,當我運行的WinForms應用程序,我得到以下錯誤:

附加信息:無法加載實體框架提供程序類型「System.Data.Entity.SqlServer.SqlProviderServices,EntityFramework.SqlServer」,該實體框架提供程序在具有不變名稱「System.Data.SqlClient」的ADO.NET提供程序的應用程序配置文件中註冊。確保使用裝配限定的名稱,並且該裝配可用於正在運行的應用程序

您認爲問題可能出在哪裏?

DAL項目的的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" /> 
    </configSections> 
    <connectionStrings> 
    <add name="ProviderInterfaceContext" connectionString="metadata=res://*/ProviderInterfaceModel.csdl|res://*/ProviderInterfaceModel.ssdl|res://*/ProviderInterfaceModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=192.168.2.12;initial catalog=ProviderInterface;user id=--;password=---;multipleactiveresultsets=True;application name=EntityFramework&quot;" providerName="System.Data.EntityClient" /> 
    </connectionStrings> 
    <entityFramework> 
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework"> 
     <parameters> 
     <parameter value="mssqllocaldb" /> 
     </parameters> 
    </defaultConnectionFactory> 
    <providers> 
     <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /> 
    </providers> 
    </entityFramework> 
    <system.serviceModel> 
    <client> 
     <endpoint address="" 
      binding="basicHttpBinding" 
      contract="PrizeServiceSoap" name="PrizeServiceSoap" /> 
    </client> 
    </system.serviceModel> 
</configuration> 

的的WinForms的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" /> 
    </configSections> 
    <connectionStrings> 
    <add name="ProviderInterfaceContext" connectionString="metadata=res://*/ProviderInterfaceModel.csdl|res://*/ProviderInterfaceModel.ssdl|res://*/ProviderInterfaceModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=192.168.2.12;initial catalog=ProviderInterface;user id=---;password=----;multipleactiveresultsets=True;application name=EntityFramework&quot;" providerName="System.Data.EntityClient" /> 
    </connectionStrings> 
    <entityFramework> 
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework"> 
     <parameters> 
     <parameter value="mssqllocaldb" /> 
     </parameters> 
    </defaultConnectionFactory> 
    <providers> 
     <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /> 
    </providers> 
    </entityFramework> 
    <startup> 
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> 
    </startup> 
</configuration> 

回答

0

固定。

添加了對EntityFramework 6.0和EntityFramework.SqlServer的引用,現在一切正在運行。

相關問題