[英]System.MissingMethodException after upgrading from EF 6.0 Beta to RC
这是什么意思?
System.MissingMethodException未被用户代码处理
HResult = -2146233069 Message =找不到方法:'System.Data.Entity.ModelConfiguration.Configuration.PrimitivePropertyConfiguration System.Data.Entity.ModelConfiguration.Configuration.StructuralTypeConfiguration1.Property(System.Linq.Expressions.Expression
12 <!0 ,! !0 >>)”。 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:
此类发生错误:
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并编辑项目文件,则可能会看到以下内容:
<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 。 删除包时,这将产生相同的行为。
我遇到了同样的错误。 它对我有用:
在我的情况下,我不得不从这个文件夹中删除EntityFramework.dll:
C:\\ WINDOWS \\ Microsoft.NET \\装配\\ GAC_MSIL \\的EntityFramework
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.