我在R#中运行单元测试时遇到以下错误,但测试在Visual Studio MSTest中按预期传递,这与任何触及实体框架的情况一起发生,其他测试工作没有问题,我认为这是因为没有部署一个DLL,但确保所有的dll都标记为deploy local = true,同时确保关闭分析,因为我读到这可能会导致R#出现问题,异常很奇怪,可以'真的找到任何押韵或理由为什么会发生这种情况。代码执行也没有问题,所以它确实告诉我R#或我的配置不好。不幸的是,我已经在R#的MSTest屏幕上尝试了所有内容,但没有运气,即使使用“使用MSTests.exe运行测试(不推荐)”,仍然所有测试都失败了,但只有在他们处理实体框架时才会失败。否则他们会毫无问题地工作。这种情况在其他同事系统中发生,因此它不仅仅是我的系统。
测试方法Calamos.Ccs.Research.Repository.Test.DatabaseContext.EntityFrameworkContexts.ResearchContext
Test.TestFactorPeriod抛出异常:System.InvalidOperationException:
类型为“Calamos.Ccs.Research.Business.Oltp.Geographic.Exchange”的属性“CountryId”上的ForeignKeyAttribute无效。在依赖类型“Calamos.Ccs.Research.Business.Oltp.Geographic.Exchange”上找不到导航属性“Country”。 Name值应该是有效的导航属性名称。
at System.Data.Entity.ModelConfiguration.Conventions.ForeignKeyPrimitivePropertyAttributeConvention.ForeignKeyAttributeConventionImpl.ApplyNavigationProperty(PropertyInfo propertyInfo,ModelConfiguration modelConfiguration,ForeignKeyAttribute foreignKeyAttribute)
System.Data上的System.Data.Entity.ModelConfiguration.Conventions.ForeignKeyPrimitivePropertyAttributeConvention.ForeignKeyAttributeConventionImpl.Apply(PropertyInfo propertyInfo,ModelConfiguration modelConfiguration,ForeignKeyAttribute foreignKeyAttribute)at System.Data.Entity.ModelConfiguration.Conventions.AttributeConfigurationConvention 3.System.Data.Entity.ModelConfiguration.Conventions.IConfigurationConvention<TMemberInfo,TConfiguration>.Apply(TMemberInfo memberInfo, Func
1 configuration) .Entity.ModelConfiguration.Conventions.ForeignKeyPrimitivePropertyAttributeConvention.System.Data.Entity.ModelConfiguration.Conventions.IConfigurationConvention.Apply(PropertyInfo memberInfo,Func 1 configuration)
at System.Data.Entity.ModelConfiguration.Configuration.ConventionsConfiguration.ApplyPropertyConfiguration(PropertyInfo propertyInfo, ModelConfiguration modelConfiguration)
at System.Data.Entity.ModelConfiguration.Mappers.TypeMapper.MapStructuralElements(Type type, ICollection
1 annotations,Action 2 propertyMappingAction, Boolean mapDeclaredPropertiesOnly, Func
1 structuralTypeConfiguration)
at System.Data.Entity.ModelConfiguration.Mappers.TypeMapper.MapEntityType(Type type)
在System.Data.Entity.ModelConfiguration.Mappers.NavigationPropertyMapper.Map(PropertyInfo propertyInfo,EdmEntityType entityType,Func 1 entityTypeConfiguration, Type sourceType)
at System.Data.Entity.ModelConfiguration.Mappers.PropertyMapper.Map(PropertyInfo propertyInfo, EdmEntityType entityType, Func
1 entityTypeConfiguration,Type sourceType)
在System.Data.Entity.ModelConfiguration.Mappers.TypeMapper。&lt;&gt; c_ DisplayClass12.b _e(PropertyMapper m,PropertyInfo p)
at System.Data.Entity.ModelConfiguration.Mappers.TypeMapper.MapStructuralElements(Type type,ICollection 1 annotations, Action
2 propertyMappingAction,Boolean mapDeclaredPropertiesOnly,Func 1 structuralTypeConfiguration)
at System.Data.Entity.ModelConfiguration.Mappers.TypeMapper.MapEntityType(Type type)
at System.Data.Entity.ModelConfiguration.Mappers.NavigationPropertyMapper.Map(PropertyInfo propertyInfo, EdmEntityType entityType, Func
1 entityTypeConfiguration,Type sourceType)
在System.Data.Entity.ModelConfiguration.Mappers.PropertyMapper.Map(PropertyInfo propertyInfo,EdmEntityType entityType,Func 1 entityTypeConfiguration, Type sourceType)
at System.Data.Entity.ModelConfiguration.Mappers.TypeMapper.<>c__DisplayClass12.<MapEntityType>b__e(PropertyMapper m, PropertyInfo p)
at System.Data.Entity.ModelConfiguration.Mappers.TypeMapper.MapStructuralElements(Type type, ICollection
1 annotations,Action 2 propertyMappingAction, Boolean mapDeclaredPropertiesOnly, Func
1 structuralTypeConfiguration)
at System.Data.Entity.ModelConfiguration.Mappers.TypeMapper.MapEntityType(Type type)
在System.Data.Entity.ModelConfiguration.Mappers.NavigationPropertyMapper.Map(PropertyInfo propertyInfo,EdmEntityType entityType,Func 1 entityTypeConfiguration, Type sourceType)
at System.Data.Entity.ModelConfiguration.Mappers.PropertyMapper.Map(PropertyInfo propertyInfo, EdmEntityType entityType, Func
1 entityTypeConfiguration,Type sourceType)
在System.Data.Entity.ModelConfiguration.Mappers.TypeMapper。&lt;&gt; c_ DisplayClass12.b _e(PropertyMapper m,PropertyInfo p)
at System.Data.Entity.ModelConfiguration.Mappers.TypeMapper.MapStructuralElements(Type type,ICollection 1 annotations, Action
2 propertyMappingAction,Boolean mapDeclaredPropertiesOnly,Func 1 structuralTypeConfiguration)
at System.Data.Entity.ModelConfiguration.Mappers.TypeMapper.MapEntityType(Type type)
at System.Data.Entity.DbModelBuilder.<>c__DisplayClass7.<MapTypes>b__1(Type type)
at System.Linq.Enumerable.WhereListIterator
1.MoveNext()
在System.Data.Entity.ModelConfiguration.Utilities.IEnumerableExtensions.Each(IEnumerable 1 ts, Action
1个动作)
在System.Data.Entity.DbModelBuilder.MapTypes(EdmModel模型)
在System.Data.Entity.DbModelBuilder.Build(DbProviderManifest providerManifest,DbProviderInfo providerInfo)
在System.Data.Entity.DbModelBuilder.Build(DbConnection providerConnection)
在System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext internalContext)
在System.Data.Entity.Internal.RetryLazy 2.GetValue(TInput input)
at System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType)
at System.Data.Entity.Internal.Linq.InternalSet
1.Initialize()
在System.Data.Entity.Internal.Linq.InternalSet 1.get_InternalContext()
at System.Data.Entity.Infrastructure.DbQuery
1.System.Linq.IQueryable.get_Provider()
在System.Linq.Queryable.FirstOrDefault(IQueryable 1 source, Expression
1谓词)
在ResearchContextTest.cs中的Calamos.Ccs.Research.Repository.Test.DatabaseContext.EntityFrameworkContexts.ResearchContextTest.TestFactorPeriod():第290行