system.missingMethodException而从升级EF 6.0 Beta版和RC之后 [英] System.MissingMethodException after upgrading from EF 6.0 Beta to RC

查看:357
本文介绍了system.missingMethodException而从升级EF 6.0 Beta版和RC之后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是什么意思?

system.missingMethodException而被用户代码结果
未处理的HResult = -2146233069留言=找不到方法:
'System.Data.Entity.ModelConfiguration.Configuration.PrimitivePropertyConfiguration
System.Data.Entity.ModelConfiguration.Configuration.StructuralTypeConfiguration 1.Property(System.Linq的。 Expressions.Expression 12 LT;!0,!! 0 GT;>)。
来源= Att.Uds.DataLayerMappings堆栈跟踪:
在Att.Uds.DataLayerMappings.ItemTypeItemConfiguration..ctor()
在Att.Uds.DataLayerMappings.UdsContext.OnModelCreating(DbModelBuilder
模型构建器)在
C:\TFS\ATS-MSDev\UDS\Dev\Code\Att.Uds.DataLayerMappings\UdsContext.cs:行
163,
。在系统.Data.Entity.DbContext.CallOnModelCreating(DbModelBuilder
模型构建器)
在System.Data.Entity.Internal.LazyInternalContext.CreateModelBuilder()
在System.Data.Entity.Internal.LazyInternalContext.CreateModel (LazyInternalContext
internalContext)
在System.Data.Entity.Internal.RetryLazy2.GetValue(TInput输入)的InnerException:

System.MissingMethodException was unhandled by user code
HResult=-2146233069 Message=Method not found: 'System.Data.Entity.ModelConfiguration.Configuration.PrimitivePropertyConfiguration System.Data.Entity.ModelConfiguration.Configuration.StructuralTypeConfiguration1.Property(System.Linq.Expressions.Expression12<!0,!!0>>)'. Source=Att.Uds.DataLayerMappings StackTrace: at Att.Uds.DataLayerMappings.ItemTypeItemConfiguration..ctor() at Att.Uds.DataLayerMappings.UdsContext.OnModelCreating(DbModelBuilder modelBuilder) in c:\TFS\ATS-MSDev\UDS\Dev\Code\Att.Uds.DataLayerMappings\UdsContext.cs:line 163 at System.Data.Entity.DbContext.CallOnModelCreating(DbModelBuilder modelBuilder) at System.Data.Entity.Internal.LazyInternalContext.CreateModelBuilder() at System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext internalContext) at System.Data.Entity.Internal.RetryLazy2.GetValue(TInput input) InnerException:

错误发生在这个类:

namespace Contoso.Fabrikam.DataLayerMappings
{ 
  public abstract class NamedEntityConfiguration<TEntity> : EntityBaseConfiguration<TEntity> where TEntity : NamedEntity
  {
    public ConfigurationColumn NameColumn;
    protected new int LastOrdinalPosition
    {
      get
      {
        return (NameColumn.Ordinal);
      }
    }
    public NamedEntityConfiguration() <=== EXCEPTION HERE
    {
      NameColumn = new ConfigurationColumn() { Ordinal = base.LastOrdinalPosition+1, Name = "Name", IsRequired = true, Length = 128 };
      this.Property(t => t.Name)
        .HasColumnName(NameColumn.Name)
        .HasColumnOrder(NameColumn.Ordinal)
        .HasMaxLength(NameColumn.Length);
      if(NameColumn.IsRequired)
      {
        this.Property(t => t.Name).IsRequired();
      }
    }
  }
}

感谢您

推荐答案

为什么@Saber他的回答是工作的原因,因为当你的项目升级到更高的.NET版本,该项目文件不会自动升级。例如,如果从.NET 4.0到.NET 4.5的升级和编辑项目文件,您可能会看到以下内容:

The reason why @Saber his answer works is because when you upgrade your project to a higher .NET Version, the project file is not upgraded automatically. For example, if you upgrade from .NET 4.0 to .NET 4.5 and edit the project file, you might see the following:

<Reference Include="EntityFramework">
      <HintPath>..\packages\EntityFramework.6.1.3\lib\net40\EntityFramework.dll</HintPath>
    </Reference>
    <Reference Include="EntityFramework.SqlServer">
      <HintPath>..\packages\EntityFramework.6.1.3\lib\net40\EntityFramework.SqlServer.dll</HintPath>
    </Reference>

您将不得不更改参考为 net45 而不是 net40 。在拆除包装,这将产生相同的行为。

You will have to change the reference to net45 instead of net40. When removing the packages, this will produce the same behaviour.

这篇关于system.missingMethodException而从升级EF 6.0 Beta版和RC之后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆