locked
meaning of "The abstract type 'X' has no mapped descendents and so cannot be mapped."? RRS feed

  • Question

  • I have searched for this message on the web and cannot find any information about it.  The exception InvalidOperationException is super generic and reveals nothing about the possible cause.  The message is the only bit with any specific information but there is no mention of this message on Microsoft's websites or any other website for that matter.

    System.InvalidOperationException was unhandled by user code
      Message=The abstract type 'NoisyKeys. ... .MyObject' has no mapped descendents and so cannot be mapped. Either remove 'NoisyKeys. ... .MyObject' from the model or add one or more types deriving from 'NoisyKeys. ... .MyObject' 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.GenerateIndependentForeignKeyConstraint(DbDatabaseMapping databaseMapping, EdmEntityType principalEntityType, EdmEntityType dependentEntityType, DbTableMetadata dependentTable, DbAssociationSetMapping associationSetMapping, DbAssociationEndMapping associationEndMapping, String name, EdmAssociationEnd principalEnd, Boolean isPrimaryKeyColumn)
           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.LazyInternalContext.CreateObjectContextForDdlOps()
           at System.Data.Entity.Database.Exists()
           at NoisyKeys.<...>.Models.ImportOps.DeleteDatabase() in C:\...\TFS-All\Main\VS2010\src\NoisyKeys.<...>\Models\ImportOps.cs:line 22
           at NoisyKeys.<...>.MvcApplication.Application_Start() in C:\...\TFS-All\Main\VS2010\src\NoisyKeys.<...>\Global.asax.cs:line 165
      InnerException: 
    

     


    I am using code first.  The class involved in the error is an abstract base class (A).  It lies in a class hierarchy that contains a generic (B).  When I hook to the abstract derived class (C) things work fine, but here I am hooking to the abstract base class (A) and it generates the aforementioned error.

    public abstract class A  // base class / superclass

    public abstract class B<,> : A

    public abstract class C : B<,>  // derived class / subclass

    public class D : C

    public abstract class AssociatedEvent : Event
    {
        public A Association { get; set; }  // C works, but A does not and triggers aforementioned error
        .
        .
        .
    }

    If I code-first a handle to C it works, but I can't get a handle to A to work.  A is the same as MyObject in the exception above.  The message mentions "has no mapped descendents" but A and C both have the same descendants (D) and referencing C works fine.  My DbContext has a DbSet<D>.

    The thread http://social.msdn.microsoft.com/Forums/en/adodotnetentityframework/thread/5dcba2d5-6f08-4c50-bbc4-51834b82205b might be related, but I don't know for sure.  I'm not quite sure I understand the content of this thread and my specific error message was not discussed there.  Also, I am receiving this error on 1/23/2012 with modern tech; that thread was in 2008.





    • Edited by NoisyKeys Tuesday, January 24, 2012 4:55 AM
    Tuesday, January 24, 2012 4:28 AM

All replies

  • It's really difficult to find the root cause of the exception.

    Thursday, February 2, 2012 8:57 AM
  • Hi NoisyKeys,

    Welcome to MSDN Forum.

    From the error message and simple classes you posted, I can hardly repro the issue. If possible, please send a sample to v-alll@microsoft.com , then I may help you more effectively.

    Best Regards


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us
    Friday, February 3, 2012 5:22 AM