简体   繁体   中英

Why can't I use Class Library with EF 6.1.3 from Asp.Net 5 MVC 6 project

I have a .net 4.5.1 class library with Entity Framework 6.1.3 Database First Model in it that works fine when i test it from my unit test project.

But when I try to use it from my ASP.NET 5 MVC 6 project (dnx451 only) I always get an error saying:

FileNotFoundException: Couldn't find file EntityFramework.resources.
at System.Reflection.RuntimeAssembly.InternalGetSatelliteAssembly(String name, CultureInfo culture, Version version, Boolean throwOnFileNotFound, StackCrawlMark& stackMark)
at System.Resources.ManifestBasedResourceGroveler.GetSatelliteAssembly(CultureInfo lookForCulture, StackCrawlMark& stackMark)

I think it used to work at first, but then it stopped working and I can't find the reason for it.

Anyone seen this error before, or know what it is??

OK, this is a bug, which is reported here: https://github.com/aspnet/dnx/issues/3047

Joplaal commented with this:

This is a very important issue, since it prevents to use very popular libraries, like Entity Framework 6 from DNX projects, when current thread culture is other than invariant culture.

While we wait for a fix, you can remove any localisation support by adding this to your Startup's Configure method.

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
    //...
    var localizationOptions = new RequestLocalizationOptions()
    {
        SupportedCultures = new List<CultureInfo> { new CultureInfo("") },
        SupportedUICultures = new List<CultureInfo> { new CultureInfo("") }
    };

    var invariantCulture = new RequestCulture(new CultureInfo(""), new CultureInfo(""));

    app.UseRequestLocalization(localizationOptions, invariantCulture);
    //...
}

I was Googling this one so hard, it had me filling out captchas.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM