我有两个项目,其中一个项目包含实体模型,充当DAL,另一个项目使用该模型并实现应用程序逻辑。
该模型是一个类库项目,该应用程序是一个Windows窗体项目。
拥有项目的以下app.config文件,并在表单项目中引用了System.Data.Entity,当我运行WinForms应用程序时,我收到以下错误:
附加信息:实体框架提供程序类型' System.Data.Entity.SqlServer.SqlProviderServices,EntityFramework.SqlServer'在具有不变名称&System; System.SData.SqlClient&无法加载。确保使用了程序集限定名称,并且程序集可用于正在运行的应用程序
您认为问题可能在哪里?
DAL Project的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>
答案 0 :(得分:0)
固定。
添加了对EntityFramework 6.0和EntityFramework.SqlServer的引用,现在一切正常。