EF6 OnModelCreating 加载数据库上下文报错

  1. 异常: System.ArgumentException: 类型为“PurchasingGatherMap”的表达式不能用于方法“System.Data.Entity.ModelConfiguration.Configuration.ConfigurationRegistrar AddRuleDtlEntity”的类型为“System.Data.Entity.ModelConfiguration.EntityTypeConfiguration1[RuleDtlEntity]”的参数 在 System.Linq.Expressions.Expression.ValidateOneArgument(MethodBase method, ExpressionType nodeKind, Expression arg, ParameterInfo pi) 在 System.Linq.Expressions.Expression.ValidateArgumentTypes(MethodBase method, ExpressionType nodeKind, ReadOnlyCollection1& arguments)
    在 System.Linq.Expressions.Expression.Call(Expression instance, MethodInfo method, IEnumerable1 arguments) 在 Microsoft.CSharp.RuntimeBinder.ExpressionTreeCallRewriter.GenerateCall(EXPRCALL pExpr) 在 Microsoft.CSharp.RuntimeBinder.ExpressionTreeCallRewriter.VisitCALL(EXPRCALL pExpr) 在 Microsoft.CSharp.RuntimeBinder.Semantics.ExprVisitorBase.Dispatch(EXPR pExpr) 在 Microsoft.CSharp.RuntimeBinder.Semantics.ExprVisitorBase.Visit(EXPR pExpr) 在 Microsoft.CSharp.RuntimeBinder.ExpressionTreeCallRewriter.GenerateLambda(EXPRCALL pExpr) 在 Microsoft.CSharp.RuntimeBinder.ExpressionTreeCallRewriter.VisitCALL(EXPRCALL pExpr) 在 Microsoft.CSharp.RuntimeBinder.Semantics.ExprVisitorBase.Dispatch(EXPR pExpr) 在 Microsoft.CSharp.RuntimeBinder.Semantics.ExprVisitorBase.Visit(EXPR pExpr) 在 Microsoft.CSharp.RuntimeBinder.ExpressionTreeCallRewriter.Rewrite(TypeManager typeManager, EXPR pExpr, IEnumerable1 listOfParameters)
    在 Microsoft.CSharp.RuntimeBinder.RuntimeBinder.CreateExpressionTreeFromResult(IEnumerable1 parameters, ArgumentObject[] arguments, Scope pScope, EXPR pResult) 在 Microsoft.CSharp.RuntimeBinder.RuntimeBinder.BindCore(DynamicMetaObjectBinder payload, IEnumerable1 parameters, DynamicMetaObject[] args, DynamicMetaObject& deferredBinding)
    在 Microsoft.CSharp.RuntimeBinder.RuntimeBinder.Bind(DynamicMetaObjectBinder payload, IEnumerable1 parameters, DynamicMetaObject[] args, DynamicMetaObject& deferredBinding) 在 Microsoft.CSharp.RuntimeBinder.BinderHelper.Bind(DynamicMetaObjectBinder action, RuntimeBinder binder, IEnumerable1 args, IEnumerable1 arginfos, DynamicMetaObject onBindingError) 在 Microsoft.CSharp.RuntimeBinder.CSharpInvokeMemberBinder.FallbackInvokeMember(DynamicMetaObject target, DynamicMetaObject[] args, DynamicMetaObject errorSuggestion) 在 System.Dynamic.DynamicMetaObject.BindInvokeMember(InvokeMemberBinder binder, DynamicMetaObject[] args) 在 System.Dynamic.InvokeMemberBinder.Bind(DynamicMetaObject target, DynamicMetaObject[] args) 在 System.Dynamic.DynamicMetaObjectBinder.Bind(Object[] args, ReadOnlyCollection1 parameters, LabelTarget returnLabel)
    在 System.Runtime.CompilerServices.CallSiteBinder.BindCore[T](CallSite1 site, Object[] args) 在 System.Dynamic.UpdateDelegates.UpdateAndExecuteVoid2[T0,T1](CallSite site, T0 arg0, T1 arg1) 在 CallSite.Target(Closure , CallSite , ConfigurationRegistrar , Object ) 在 DataBase.Oracle.DatabaseContext.OnModelCreating(DbModelBuilder modelBuilder) 位置 DataBase.EF.Oracle\DatabaseContext.cs:行号 58 在 System.Data.Entity.Internal.LazyInternalContext.CreateModelBuilder() 在 System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext internalContext) 在 System.Data.Entity.Internal.RetryLazy2.GetValue(TInput input)
    在 System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
    在 System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType)
    在 System.Data.Entity.Internal.Linq.InternalSet1.Initialize() 在 System.Data.Entity.Internal.Linq.InternalSet1.get_InternalContext()
    在 System.Data.Entity.Internal.Linq.InternalSet1.Find(Object[] keyValues) 在 System.Data.Entity.DbSet1.Find(Object[] keyValues)
    在 DataBase.Oracle.Database.FindEntity[T](Object keyValue) 位置 Db\Learun.DataBase.EF.Oracle\Database.cs:行号 350
    在 DataBase.Repository.Repository.FindEntity[T](Object keyValue) 位置 Db\DataBase.Repository\Repository.cs:行号 300

把你的 OnModelCreating 相关代码贴一下
你是 ModelFirst 么?应该是模型定义有问题。

UP UP UP