[英]System.MissingMethodException after upgrading from EF 6.0 Beta to RC
what does this mean? 这是什么意思?
System.MissingMethodException was unhandled by user code
System.MissingMethodException未被用户代码处理
HResult=-2146233069 Message=Method not found: 'System.Data.Entity.ModelConfiguration.Configuration.PrimitivePropertyConfiguration System.Data.Entity.ModelConfiguration.Configuration.StructuralTypeConfiguration1.Property(System.Linq.Expressions.Expression
12<!0,!!0>>)'.HResult = -2146233069 Message =找不到方法:'System.Data.Entity.ModelConfiguration.Configuration.PrimitivePropertyConfiguration System.Data.Entity.ModelConfiguration.Configuration.StructuralTypeConfiguration
1.Property(System.Linq.Expressions.Expression
12 <!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:Source = Att.Uds.DataLayerMappings StackTrace:位于att.Uds.DataLayerMappings.ItemTypeItemConfiguration..ctor()at at.Uds.DataLayerMappings.UdsContext.OnModelCreating(DbModelBuilder modelBuilder)in c:\\ TFS \\ ATS-MSDev \\ UDS \\ Dev \\ Code \\ Att.Uds.DataLayerMappings \\ UdsContext.cs:位于System.Data.Entity.Internal.RazyInternalContext.CreateModelBuilder()处System.Data.Entity.Internal的System.Data.Entity.DbContext.CallOnModelCreating(DbModelBuilder modelBuilder)的第163行System.Data.Entity.Internal.RetryLazy2.GetValue(TInput输入)中的.LazyInternalContext.CreateModel(LazyInternalContext internalContext)InnerException:
Error happens on this class: 此类发生错误:
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();
}
}
}
}
Thank you 谢谢
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. @Saber他的答案之所以有效,是因为当您将项目升级到更高的.NET版本时,项目文件不会自动升级。 For example, if you upgrade from .NET 4.0 to .NET 4.5 and edit the project file, you might see the following:
例如,如果从.NET 4.0升级到.NET 4.5并编辑项目文件,则可能会看到以下内容:
<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>
You will have to change the reference to net45 instead of net40 . 您必须将引用更改为net45而不是net40 。 When removing the packages, this will produce the same behaviour.
删除包时,这将产生相同的行为。
I've encountered same error. 我遇到了同样的错误。 It worked for me:
它对我有用:
In my case I had to remove the EntityFramework.dll from this folder: 在我的情况下,我不得不从这个文件夹中删除EntityFramework.dll:
C:\\Windows\\Microsoft.NET\\assembly\\GAC_MSIL\\EntityFramework C:\\ WINDOWS \\ Microsoft.NET \\装配\\ GAC_MSIL \\的EntityFramework
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.