gpt4 book ai didi

c# - 从 EF 6.0 Beta 升级到 RC 后出现 System.MissingMethodException

转载 作者:太空狗 更新时间:2023-10-30 00:07:43 28 4
gpt4 key购买 nike

这是什么意思?

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 并编辑项目文件,您可能会看到以下内容:

<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。删除包时,这将产生相同的行为。

关于c# - 从 EF 6.0 Beta 升级到 RC 后出现 System.MissingMethodException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18881575/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com