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="data source=192.168.2.12;initial catalog=ProviderInterface;user id=--;password=---;multipleactiveresultsets=True;application name=EntityFramework"" 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="data source=192.168.2.12;initial catalog=ProviderInterface;user id=---;password=----;multipleactiveresultsets=True;application name=EntityFramework"" 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>