启动EF4 CF CTP5应用程序时断言失败 [英] Assert Failure when starting EF4 CF CTP5 Application

查看:64
本文介绍了启动EF4 CF CTP5应用程序时断言失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

启动应用程序时出现以下错误。

I get the following error when I start my application.

我附加下面的调试器后抛出异常。这是一个
链接到我的解决方案(压缩)

There's an exception throw after I attach the debugger which is below. Here is a link to my solution (zipped).

我喜欢这里的一些帮助,因为例外错误没有意义,因为所列实体上有一个公共属性。

I'd love some assistance here as the exception error doesn't make sense given that there is a public property of the name on the entity listed.

未处理Sysem.InvalidOperationException消息=外键组件"DivisionId"为不是实体'DivisionInSeason'的已申报财产。验证它是否未从模型中明确排除,并且它是有效的原始属性。

Sysem.InvalidOperationException was unhandled Message=The foreign key component 'DivisionId' is not a declared property on the entity 'DivisionInSeason'. Verify that it has not been explicitly excluded from the model and that it is a valid primitive property.

Source = EntityFramework StackTrace:服务器堆栈跟踪:在System.Data.Entity.ModelConfiguration.Configuration System.Data.Entity上的System.Data.Entity.ModelConfiguration.Configuration.Properties.Navigation.NavigationPropertyConfiguration.ConfigureConstraint(EdmAssociationType
associationType,EdmAssociationEnd dependentEnd)中的.Properties.Navigation.ForeignKeyConstraintConfiguration.Configure(EdmAssociationType associationType,EdmAssociationEnd dependentEnd) System.Data.Entity.ModelConfiguration.Configuration.Properties.Navigation.NavigationPropertyConfiguration.Configure(EdmNavigationProperty
navigationProperty,EdmModel model)中的.ModelConfiguration.Configuration.Properties.Navigation.NavigationPropertyConfiguration.ConfigureDependentBehavior(EdmAssociationType associationType,EdmModel model) .Data.Entity.ModelConfiguration.Configuration.Types.Ent在System.Data.Entity.ModelConfiguration.Configuration.ModelConfiguration的System.Data.Entity.ModelConfiguration.Configuration.Types.EntityTypeConfiguration.Configure(EdmEntityType
entityType,EdmModel model)中的ityTypeConfiguration.ConfigureAssociations(EdmEntityType entityType,EdmModel model)。 System.Data.Entity.ModelConfiguration.Configuration.ModelConfiguration.Configure(EdmModel model)中的SystemEntities(EdmModel模型)位于System.Data.Entity.ModelConfiguration.ModelBuilder.Build(DbProviderManifest
providerManifest,DbProviderInfo providerInfo,Boolean validateModel)at at System.Data.Entity.ModelConfiguration.ModelBuilder.Build(DbConnection providerConnection)位于System.LazyInternalContext.CreateModel()at System.Lazy`1.CreateValue()
异常重新抛出[0]:在System.Data.Entity.ModelConfiguration.Configuration.Properties.Navigation.ForeignKeyConstraintConfiguration.Configure(EdmAssociationType associationType,EdmAssociationEnd dependentEnd )System.Data.Entity.ModelConfiguration.Properties.Navigation.NavigationPropertyConfiguration.Conpertigure.Navigation.NavigationPropertyConfiguration.ConfigureConstraint(EdmAssociationType
associationType,EdmAssociationEnd dependentEnd)at System.Data.Entity.ModelConfiguration.Configuration.Properties.Navigation.NavigationPropertyConfiguration.ConfigureDependentBehavior(EdmAssociationType)在System.Data.Entity.ModelConfiguration.Configuration.Types.EntityTypeConfiguration.ConfigureAssociations的System.Data.Entity.ModelConfiguration.Configuration.Properties.Navigation.NavigationPropertyConfiguration.Configure(EdmNavigationProperty
navigationProperty,EdmModel model)上的associationType,EdmModel model) (EdmEntityType entityType,EdmModel model)System.Data.Entity.ModelConfiguration.Configuration.Types.EntityTypeConfiguration.Configure(EdmEntityType
entityType,EdmModel model)System.Data.Entity.ModelConfiguration.Configuration.ModelConfiguration.ConfigureEntities(EdmModel) System.Data.Entity.Mo上的模型) System.Data.Entity.ModelConfiguration.ModelBuilder.Build上的System.Data.Entity.ModelConfiguration.ModelBuilder.Build(DbProviderManifest
providerManifest,DbProviderInfo providerInfo,Boolean validateModel)中的delConfiguration.Configuration.ModelConfiguration.Configure(EdmModel模型) System.La中的System.Data.Entity.Internal.LazyInternalContext.CreateModel()处的System.Data.Empity.CreateModel()处的System.LazyInitValue()处的System.Lazy`1.LazyInitValue()处的
处的DbConnection providerConnection( )System.Data.Entity.Internal.text.Initialize()的System.Data.Entity.Internal.LazyInternalContext.InitializeContext()位于System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type
entityType)at at在System.Data.Entity.Internal.Linq.InternalSet`1的System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext()中的System.Data.Entity.Internal.Linq.InternalSet`1.Initialize()。系统中的ActOnSet(Action action,EntityState newState,Object entity,
String methodName)位于C:\\的EFCF.Program.Main(String [] args)的System.Data.Entity.DbSet`1.Add(TEntity实体)的.Data.Entity.Internal.Linq.InternalSet`1.Add(Object entity) \\ system.AppDomain.ExecuteAssembly(String assemblyFile,Evidence assemblySecurity ,String [] args)在Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()中的System.Threading.ThreadHelper.ThreadStart_Context(对象状态)
在System.Threading.ExecutionContext.Run(ExecutionContext executionContext,ContextCallback callback,Object在
的System.Threading.ExecutionContext.Run(ExecutionContext executionContext,ContextCallback回调,对象状态)中的state,Boolean ignoreSyncCtx)System.Threading.ThreadHelper.ThreadStart()InnerException:

Source=EntityFramework StackTrace: Server stack trace: at System.Data.Entity.ModelConfiguration.Configuration.Properties.Navigation.ForeignKeyConstraintConfiguration.Configure(EdmAssociationType associationType, EdmAssociationEnd dependentEnd) at System.Data.Entity.ModelConfiguration.Configuration.Properties.Navigation.NavigationPropertyConfiguration.ConfigureConstraint(EdmAssociationType associationType, EdmAssociationEnd dependentEnd) at System.Data.Entity.ModelConfiguration.Configuration.Properties.Navigation.NavigationPropertyConfiguration.ConfigureDependentBehavior(EdmAssociationType associationType, EdmModel model) at System.Data.Entity.ModelConfiguration.Configuration.Properties.Navigation.NavigationPropertyConfiguration.Configure(EdmNavigationProperty navigationProperty, EdmModel model) at System.Data.Entity.ModelConfiguration.Configuration.Types.EntityTypeConfiguration.ConfigureAssociations(EdmEntityType entityType, EdmModel model) at System.Data.Entity.ModelConfiguration.Configuration.Types.EntityTypeConfiguration.Configure(EdmEntityType entityType, EdmModel model) at System.Data.Entity.ModelConfiguration.Configuration.ModelConfiguration.ConfigureEntities(EdmModel model) at System.Data.Entity.ModelConfiguration.Configuration.ModelConfiguration.Configure(EdmModel model) at System.Data.Entity.ModelConfiguration.ModelBuilder.Build(DbProviderManifest providerManifest, DbProviderInfo providerInfo, Boolean validateModel) at System.Data.Entity.ModelConfiguration.ModelBuilder.Build(DbConnection providerConnection) at System.Data.Entity.Internal.LazyInternalContext.CreateModel() at System.Lazy`1.CreateValue() Exception rethrown at [0]: at System.Data.Entity.ModelConfiguration.Configuration.Properties.Navigation.ForeignKeyConstraintConfiguration.Configure(EdmAssociationType associationType, EdmAssociationEnd dependentEnd) at System.Data.Entity.ModelConfiguration.Configuration.Properties.Navigation.NavigationPropertyConfiguration.ConfigureConstraint(EdmAssociationType associationType, EdmAssociationEnd dependentEnd) at System.Data.Entity.ModelConfiguration.Configuration.Properties.Navigation.NavigationPropertyConfiguration.ConfigureDependentBehavior(EdmAssociationType associationType, EdmModel model) at System.Data.Entity.ModelConfiguration.Configuration.Properties.Navigation.NavigationPropertyConfiguration.Configure(EdmNavigationProperty navigationProperty, EdmModel model) at System.Data.Entity.ModelConfiguration.Configuration.Types.EntityTypeConfiguration.ConfigureAssociations(EdmEntityType entityType, EdmModel model) at System.Data.Entity.ModelConfiguration.Configuration.Types.EntityTypeConfiguration.Configure(EdmEntityType entityType, EdmModel model) at System.Data.Entity.ModelConfiguration.Configuration.ModelConfiguration.ConfigureEntities(EdmModel model) at System.Data.Entity.ModelConfiguration.Configuration.ModelConfiguration.Configure(EdmModel model) at System.Data.Entity.ModelConfiguration.ModelBuilder.Build(DbProviderManifest providerManifest, DbProviderInfo providerInfo, Boolean validateModel) at System.Data.Entity.ModelConfiguration.ModelBuilder.Build(DbConnection providerConnection) at System.Data.Entity.Internal.LazyInternalContext.CreateModel() at System.Lazy`1.CreateValue() at System.Lazy`1.LazyInitValue() at System.Lazy`1.get_Value() at System.Data.Entity.Internal.LazyInternalContext.InitializeContext() at System.Data.Entity.Internal.InternalContext.Initialize() at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) at System.Data.Entity.Internal.Linq.InternalSet`1.Initialize() at System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext() at System.Data.Entity.Internal.Linq.InternalSet`1.ActOnSet(Action action, EntityState newState, Object entity, String methodName) at System.Data.Entity.Internal.Linq.InternalSet`1.Add(Object entity) at System.Data.Entity.DbSet`1.Add(TEntity entity) at EFCF.Program.Main(String[] args) in c:\src\Projects\EFCF\EFCF\Program.cs:line 16 at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() InnerException:

推荐答案

已修复!

我的OnModelCreating(...)

I had this in my OnModelCreating(...)


       modelBuilder.Entity<TeamInDivision>()
        .HasRequired(u => u.Division)
        .WithRequiredPrincipal()
        .WillCascadeOnDelete(false);

      modelBuilder.Entity<PlayerOnTeam>()
        .HasRequired(u => u.Team)
        .WithRequiredPrincipal()
        .WillCascadeOnDelete(false);


这篇关于启动EF4 CF CTP5应用程序时断言失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆