本文介绍了实体框架7错误:" EntityFramework.Core.resources"缺少(7.0.0-RC1决赛)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

[解决]参见我的答案

我有一个项目,ASP.NET 5 EF7运行。

我有我的EF模型,类库,框架4.5.1。当我尝试与数据交互,我有这样的例外:文件EntityFramework.Core.resources丢失。但是,当我把EF模型在我的UI项目,它工作正常。
任何想法是怎么回事?是否有可能有一个专门的类库中的实体框架模型? (我一直这样做的方式,但也许它已经与这个版本的变化)

这是类库包含了谁我EF7的的DbContext的package.config的内容:

 <?XML版本=1.0编码=UTF-8&GT?;
<套餐及GT;
  <包ID =EntityFramework.Commands版本=7.0.0-RC1决赛targetFramework =net451/>
  <包ID =EntityFramework.Core版本=7.0.0-RC1决赛targetFramework =net451/>
  <包ID =EntityFramework.MicrosoftSqlServer版本=7.0.0-RC1决赛targetFramework =net451/>
  <包ID =EntityFramework.MicrosoftSqlServer.Design版本=7.0.0-RC1决赛targetFramework =net451/>
  <包ID =EntityFramework.Relational版本=7.0.0-RC1决赛targetFramework =net451/>
  <包ID =EntityFramework.Relational.Design版本=7.0.0-RC1决赛targetFramework =net451/>
  <包ID =IX-异步版本=1.2.5targetFramework =net451/>
  <包ID =Microsoft.Extensions.Caching.Abstractions版本=1.0.0-RC1决赛targetFramework =net451/>
  <包ID =Microsoft.Extensions.Caching.Memory版本=1.0.0-RC1决赛targetFramework =net451/>
  <包ID =Microsoft.Extensions.Configuration版本=1.0.0-RC1决赛targetFramework =net451/>
  <包ID =Microsoft.Extensions.Configuration.Abstractions版本=1.0.0-RC1决赛targetFramework =net451/>
  <包ID =Microsoft.Extensions.Configuration.Binder版本=1.0.0-RC1决赛targetFramework =net451/>
  <包ID =Microsoft.Extensions.DependencyInjection版本=1.0.0-RC1决赛targetFramework =net451/>
  <包ID =Microsoft.Extensions.DependencyInjection.Abstractions版本=1.0.0-RC1决赛targetFramework =net451/>
  <包ID =Microsoft.Extensions.Logging版本=1.0.0-RC1决赛targetFramework =net451/>
  <包ID =Microsoft.Extensions.Logging.Abstractions版本=1.0.0-RC1决赛targetFramework =net451/>
  <包ID =Microsoft.Extensions.OptionsModel版本=1.0.0-RC1决赛targetFramework =net451/>
  <包ID =Microsoft.Extensions.Primitives版本=1.0.0-RC1决赛targetFramework =net451/>
  <包ID =Remotion.Linq版本=2.0.1targetFramework =net451/>
  <包ID =System.Collections.Immutable版本=1.1.36targetFramework =net451/>
  <包ID =System.Diagnostics.DiagnosticSource版本=4.0.0-β-23516targetFramework =net451/>
  <包ID =System.Diagnostics.Tracing版本=4.0.0targetFramework =net451/>
  <包ID =System.Runtime版本=4.0.0targetFramework =net451/>
  <包ID =的System.Threading版本=4.0.0targetFramework =net451/>
< /包>

和堆栈跟踪:

  A System.Reflection.RuntimeAssembly.InternalGetSatelliteAssembly(字符串名称,CultureInfo的文化,版本版本,布尔throwOnFileNotFound,StackCrawlMark&安培; stackMark)àSystem.Resources.ManifestBasedResourceGroveler.GetSatelliteAssembly(CultureInfo的lookForCulture,StackCrawlMark和放大器; stackMark)àSystem.Resources.ManifestBasedResourceGroveler.GrovelForResourceSet(CultureInfo的文化,Dictionary2 localResourceSets,布尔tryParents,布尔createIfNotExists,StackCrawlMark&安培; stackMark)
àSystem.Resources.ResourceManager.InternalGetResourceSet(CultureInfo的requestedCulture,布尔createIfNotExists,布尔tryParents,StackCrawlMark&安培; stackMark)
àSystem.Resources.ResourceManager.InternalGetResourceSet(CultureInfo的文化,布尔createIfNotExists,布尔tryParents)
àSystem.Resources.ResourceManager.GetString(字符串名称,CultureInfo的文化)
àSystem.Resources.ResourceManager.GetString(字符串名称)
àMicrosoft.Data.Entity.Internal.CoreStrings.GetString(字符串名称,字符串[] formatterNames)
àMicrosoft.Data.Entity.Internal.CoreStrings.LogExceptionDuringQueryIteration(对象换行,对象错误)
一个Microsoft.Data.Entity.Query.Internal.QueryCompiler.<>c__181.<CompileQuery>b__18_3(Exception五) Microsoft.Data.Entity.Extensions.Internal.CoreLoggerExtensions.<>c__DisplayClass0_01.b__0(Object _,例外五)
àMicrosoft.Extensions.Logging.Debug.DebugLogger.Log(LogLevel的日志级别的Int32事件ID,对象状态,异常例外,FUNC3格式)àMicrosoft.Extensions.Logging.Logger.Log(LogLevel的日志级别的Int32事件ID,对象状态,异常异常,FUNC3格式化)


解决方案

我终于找到了,它是相对于这个问题:
      -
      -

这是一个DNX错误,但同时,我们等待一个修补程序,您可以添加到您启动的配置方法:

 公共无效配置(IApplicationBuilder应用程序,IHostingEnvironment ENV,ILoggerFactory的LoggerFactory)
{
    // ...
    VAR localizationOptions =新RequestLocalizationOptions()
    {
        SupportedCultures =新的List&LT;&的CultureInfo GT; {新的CultureInfo()},
        SupportedUICultures =新的List&LT;&的CultureInfo GT; {新的CultureInfo()}
    };    VAR InvariantCulture的=新RequestCulture(新的CultureInfo(),新的CultureInfo());    app.UseRequestLocalization(localizationOptions,InvariantCulture的);
    // ...
}

[SOLVED] see my answer

I have a project running with ASP.NET 5 and EF7.

I have my EF model in a class library, framework 4.5.1. When I try to interact with data, I have this exception : the file "EntityFramework.Core.resources" is missing. But when I put the EF model in my UI project, it works fine.Any idea what's going on ? Is it possible to have the entity framework model in a dedicated class library ? (I always did this way but maybe it has changed with this version)

This is the package.config's content of the class library who contains my EF7's DbContext :

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="EntityFramework.Commands" version="7.0.0-rc1-final" targetFramework="net451" />
  <package id="EntityFramework.Core" version="7.0.0-rc1-final" targetFramework="net451" />
  <package id="EntityFramework.MicrosoftSqlServer" version="7.0.0-rc1-final" targetFramework="net451" />
  <package id="EntityFramework.MicrosoftSqlServer.Design" version="7.0.0-rc1-final" targetFramework="net451" />
  <package id="EntityFramework.Relational" version="7.0.0-rc1-final" targetFramework="net451" />
  <package id="EntityFramework.Relational.Design" version="7.0.0-rc1-final" targetFramework="net451" />
  <package id="Ix-Async" version="1.2.5" targetFramework="net451" />
  <package id="Microsoft.Extensions.Caching.Abstractions" version="1.0.0-rc1-final" targetFramework="net451" />
  <package id="Microsoft.Extensions.Caching.Memory" version="1.0.0-rc1-final" targetFramework="net451" />
  <package id="Microsoft.Extensions.Configuration" version="1.0.0-rc1-final" targetFramework="net451" />
  <package id="Microsoft.Extensions.Configuration.Abstractions" version="1.0.0-rc1-final" targetFramework="net451" />
  <package id="Microsoft.Extensions.Configuration.Binder" version="1.0.0-rc1-final" targetFramework="net451" />
  <package id="Microsoft.Extensions.DependencyInjection" version="1.0.0-rc1-final" targetFramework="net451" />
  <package id="Microsoft.Extensions.DependencyInjection.Abstractions" version="1.0.0-rc1-final" targetFramework="net451" />
  <package id="Microsoft.Extensions.Logging" version="1.0.0-rc1-final" targetFramework="net451" />
  <package id="Microsoft.Extensions.Logging.Abstractions" version="1.0.0-rc1-final" targetFramework="net451" />
  <package id="Microsoft.Extensions.OptionsModel" version="1.0.0-rc1-final" targetFramework="net451" />
  <package id="Microsoft.Extensions.Primitives" version="1.0.0-rc1-final" targetFramework="net451" />
  <package id="Remotion.Linq" version="2.0.1" targetFramework="net451" />
  <package id="System.Collections.Immutable" version="1.1.36" targetFramework="net451" />
  <package id="System.Diagnostics.DiagnosticSource" version="4.0.0-beta-23516" targetFramework="net451" />
  <package id="System.Diagnostics.Tracing" version="4.0.0" targetFramework="net451" />
  <package id="System.Runtime" version="4.0.0" targetFramework="net451" />
  <package id="System.Threading" version="4.0.0" targetFramework="net451" />
</packages>

And the StackTrace :

à System.Reflection.RuntimeAssembly.InternalGetSatelliteAssembly(String name, CultureInfo culture, Version version, Boolean throwOnFileNotFound, StackCrawlMark& stackMark) à System.Resources.ManifestBasedResourceGroveler.GetSatelliteAssembly(CultureInfo lookForCulture, StackCrawlMark& stackMark) à System.Resources.ManifestBasedResourceGroveler.GrovelForResourceSet(CultureInfo culture, Dictionary2 localResourceSets, Boolean tryParents, Boolean createIfNotExists, StackCrawlMark& stackMark)
à System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo requestedCulture, Boolean createIfNotExists, Boolean tryParents, StackCrawlMark& stackMark)
à System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture, Boolean createIfNotExists, Boolean tryParents)
à System.Resources.ResourceManager.GetString(String name, CultureInfo culture)
à System.Resources.ResourceManager.GetString(String name)
à Microsoft.Data.Entity.Internal.CoreStrings.GetString(String name, String[] formatterNames)
à Microsoft.Data.Entity.Internal.CoreStrings.LogExceptionDuringQueryIteration(Object newline, Object error)
à Microsoft.Data.Entity.Query.Internal.QueryCompiler.<>c__181.<CompileQuery>b__18_3(Exception e) à Microsoft.Data.Entity.Extensions.Internal.CoreLoggerExtensions.<>c__DisplayClass0_01.b__0(Object _, Exception e)
à Microsoft.Extensions.Logging.Debug.DebugLogger.Log(LogLevel logLevel, Int32 eventId, Object state, Exception exception, Func3 formatter) à Microsoft.Extensions.Logging.Logger.Log(LogLevel logLevel, Int32 eventId, Object state, Exception exception, Func3 formatter)
解决方案

I finally found, it's relative to this issues : - https://github.com/aspnet/dnx/issues/3047 - https://github.com/aspnet/EntityFramework/issues/4422

It's a dnx bug but while we waiting for a fix, you can add 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);
    //...
}

这篇关于实体框架7错误:&QUOT; EntityFramework.Core.resources&QUOT;缺少(7.0.0-RC1决赛)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 15:19