c#-实体框架5-抽象类型’X’没有映射的后代,因此无法映射
作者:互联网
尝试在this object上操作时出现以下错误.有人有想法吗? project在GitHub上,但是除非周围有FIX服务器,否则您极有可能无法运行它.我似乎无法联网此错误消息.
System.InvalidOperationException was unhandled by user code
Message=The abstract type 'QuickFix.Fields.IField' has no mapped descendents and so cannot be mapped. Either remove 'QuickFix.Fields.IField' from the model or add one or more types deriving from 'QuickFix.Fields.IField' to the model.
Source=EntityFramework
StackTrace:
at System.Data.Entity.ModelConfiguration.Edm.Services.StructuralTypeMappingGenerator.GetEntityTypeMappingInHierarchy(DbDatabaseMapping databaseMapping, EdmEntityType entityType)
at System.Data.Entity.ModelConfiguration.Edm.Services.AssociationTypeMappingGenerator.GenerateIndependentAssociationType(EdmAssociationType associationType, DbDatabaseMapping databaseMapping)
at System.Data.Entity.ModelConfiguration.Edm.Services.AssociationTypeMappingGenerator.Generate(EdmAssociationType associationType, DbDatabaseMapping databaseMapping)
at System.Data.Entity.ModelConfiguration.Edm.Services.DatabaseMappingGenerator.GenerateAssociationTypes(EdmModel model, DbDatabaseMapping databaseMapping)
at System.Data.Entity.ModelConfiguration.Edm.Services.DatabaseMappingGenerator.Generate(EdmModel model)
at System.Data.Entity.ModelConfiguration.Edm.EdmModelExtensions.GenerateDatabaseMapping(EdmModel model, DbProviderManifest providerManifest)
at System.Data.Entity.DbModelBuilder.Build(DbProviderManifest providerManifest, DbProviderInfo providerInfo)
at System.Data.Entity.DbModelBuilder.Build(DbConnection providerConnection)
at System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext internalContext)
at System.Data.Entity.Internal.RetryLazy`2.GetValue(TInput input)
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
解决方法:
QuickFix Message对象不是简单的DTO,这使它们不适合使用任何ORM映射到数据库. QuickFix为每种FIX字段类型定义了一个不同的IField派生类.这意味着您将必须将IField接口映射到数据库以及每个单独的字段类型.
更糟的是,QuickFix / N是Java的移植版,其中包含许多Javaism,这使得映射非常困难,例如使用getter / setter方法代替属性.
另一个障碍是,每个FIX版本都有一个单独的名称空间,这意味着如果要为所有FIX版本保留消息,则必须使用稍微相同的类来映射4-5个不同的名称空间.
更好的选择是创建单独的DTO对象,您可以将其映射到数据库并将QuickFix Message对象转换为DTO.幸运的是,QuickFix包含XML格式的各种版本的FIX的数据字典,您可以使用它们使用代码生成器生成DTO.
为了简化转换,您可以使用基于约定的工具(例如AutoMapper)将QuickFix对象转换为DTO,而无需自己编写转换代码.
标签:quickfix,entity-framework-5,fix-protocol,c,entity-framework 来源: https://codeday.me/bug/20191031/1978956.html