user5665388
user5665388

Reputation: 53

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??

Upvotes: 2

Views: 1066

Answers (1)

Evil Pigeon
Evil Pigeon

Reputation: 1976

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.

Upvotes: 4

Related Questions