开发者

Entity Framework issue - "Mixed mode assembly...cannot be loaded in the 4.0 runtime without additional configuration information"

开发者 https://www.devze.com 2023-01-17 19:32 出处:网络
I have a UI & Library project for the solution where I\'m having the problem.The library project uses Entity Framework & the unit tests work OK with it.The project is a C# 4.0 WPF application.

I have a UI & Library project for the solution where I'm having the problem. The library project uses Entity Framework & the unit tests work OK with it. The project is a C# 4.0 WPF application.

To try to get a basic EF line of code working I copied the connection string from the Library project app.config to the UI project app.config.

When I run the project开发者_StackOverflow中文版 with a simple EF test couple of lines (see below) I get the error below. Note that both projects are set to use the .NET Framework 4 already. I do use other libraries such as Quartz.Net, however everything works fine until I include the below line.

Any suggestions re how to correct this issue?

    // Test ONly
    using (var dbContext = new Model1Container())
    {
        Debug.WriteLine("Total Usages = " + dbContext.Usages.Count());
    }

Error:

"Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information."

Connection String I copied into the UI project app.config

  <connectionStrings>
    <add name="Model1Container" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SQLite;provider connection string='data source=&quot;C:\Documents and Settings\Owner\My Documents\My Dropbox\source\MyInternetUsage\MyInternetUsageLibrary\MyInternetUsage.sqlite&quot;'" providerName="System.Data.EntityClient" />
  </connectionStrings>


Add the following directive to your app.config

<startup useLegacyV2RuntimeActivationPolicy="true">
  <supportedRuntime version="v4.0"/>
</startup>

This should fix your mixed mode problem.

0

精彩评论

暂无评论...
验证码 换一张
取 消