Entity Framework 5 - The abstract type "X" has no mapped children and therefore cannot be mapped

I get the following error when trying to use this object . Does anyone have any idea? The project is located on GitHub, but you most likely will not be able to launch it if you do not have FIX . I cannot submit this error message online.

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 
+3
c # entity-framework-5 entity-framework fix quickfix
source share
2 answers

The QuickFix Message object is not just a DTO, which makes them unsuitable for matching with a database using any ORM. QuickFix defines a different class derived from IFIL for each type of FIX field. This means that you will need to map the IField interface to the database and each individual field type.

To make matters worse, QuickFix / N is a port from Java with many Javaisms, which makes mapping very difficult, for example. using getter / setter methods instead of properties. An additional obstacle is having a separate namespace for each version of FIX, which means that you will need to display 4-5 different namespaces with slightly the same classes if you want to keep messages for all versions of FIX.

It’s best to create separate DTO objects that you can map to the database and convert from the object QuickFix messages to your DTOs. Fortunately, QuickFix includes data dictionaries for various versions of FIX in XML form, which you can use to generate your DTOs using a code generator.

To simplify the conversion, you can use a convention-based tool such as AutoMapper to convert QuickFix objects to your DTO without writing the conversion code itself.

+2
source share

Now this is a pretty useful error message.

The abstract type "QuickFix.Fields.IField" has no mapped children and therefore cannot be mapped. Either remove “QuickFix.Fields.IField” from the model, or add one or more types from “QuickFix.Fields.IField” to the model.

Apparently you have an abstract IField class (interface?) And you are trying to assemble them from your context. If this is an abstract class, you need to have one or more derived classes (defined by the discriminator column) so that EF can materialize the query results.

If this is an interface, you should not map the interface, but the class that implements it.

+2
source share

All Articles