문제

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
도움이 되었습니까?

해결책

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.

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top