[英]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.