Entity Framework 5 - The abstract type 'X' has no mapped descendents and so cannot be mapped
Asked Answered
Y

2

3

I'm getting the following error when trying to operate on this object. Anybody got any ideas? The project is on GitHub, but you will most likely not be able to run it unless you have a FIX server laying around. I can't seem to internet this error message.

    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
Yoicks answered 21/9, 2012 at 20:51 Comment(0)
W
2

QuickFix Message object are not simple DTOs which makes them unsuitable for mapping to a database using any ORM. QuickFix defines a different IField-derived class for each FIX field type. This means that you will have to map both 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 that make mapping very difficult, e.g. using getter/setter methods instead of properties. An additional obstacle is that there is a separate namespace for each FIX version, which means you will have to map 4-5 different namespaces with somewhat identical classes if you want to persist messages for all FIX versions.

A much better option is to create separate DTO objects which you can map to the database and convert from QuickFix Message object 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 make conversion easier, you can use a convention-based tool like AutoMapper to convert QuickFix objects to your DTOs without writing the conversion code yourself.

Whetstone answered 12/12, 2012 at 14:29 Comment(0)
T
2

Now this is a pretty helpful error 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.

Apparently you've got an abstract class (interface?) IField and you're trying to get a collection of these from your context. When it is an abstract class you need to have one or more derived classes (defined by a discriminator column) for EF to be able to materialize the query results.

If it is an interface, you should not map the interface but a class implementing it.

Toxophilite answered 25/9, 2012 at 16:59 Comment(0)
W
2

QuickFix Message object are not simple DTOs which makes them unsuitable for mapping to a database using any ORM. QuickFix defines a different IField-derived class for each FIX field type. This means that you will have to map both 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 that make mapping very difficult, e.g. using getter/setter methods instead of properties. An additional obstacle is that there is a separate namespace for each FIX version, which means you will have to map 4-5 different namespaces with somewhat identical classes if you want to persist messages for all FIX versions.

A much better option is to create separate DTO objects which you can map to the database and convert from QuickFix Message object 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 make conversion easier, you can use a convention-based tool like AutoMapper to convert QuickFix objects to your DTOs without writing the conversion code yourself.

Whetstone answered 12/12, 2012 at 14:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.