Note that there are some explanatory texts on larger screens.

plurals
  1. POMultiple inheritance with Entity Framework TPC
    primarykey
    data
    text
    <p>I tried to map some classes using Entity Framework in TPC style and got the following error:</p> <blockquote> <p>Error: The type 'A' cannot be mapped as defined because it maps inherited properties from types that use entity splitting or another form of inheritance. Either choose a different inheritance mapping strategy so as to not map inherited properties, or change all types in the hierarchy to map inherited properties and to not use splitting.</p> </blockquote> <p>This error occurs when I use the following classes:</p> <pre><code>public abstract class BaseEntityTest public abstract class BaseEntityTest2 : BaseEntityTest public abstract class BaseEntityTest3 : BaseEntityTest2 public class A: BaseEntityTest3 // this class is the only one with a table in the db </code></pre> <p>In the OnModelCreating method I added the following code to get the TPC mapping</p> <pre><code>modelBuilder.Entity&lt;A&gt;().Map(m =&gt; { m.MapInheritedProperties(); m.ToTable("A"); }); </code></pre> <p>When I exclude BaseEntityTest2 from the structure (so that A inherits only from BaseEntityTest instead of BaseEntityTest2) the error goes away. Does that mean that it is not possible to create this mapping or do I just miss something?</p> <p>EDIT:</p> <p>Properties of classes:</p> <pre><code>public abstract class BaseEntityTest { [Key] public Guid Id { get; set; } public String Info { get; set; } [Required] public DateTime CreationDate { get; set; } [Required] public String CreationUser { get; set; } [Required] public DateTime ModificationDate { get; set; } [Required] public String ModificationUser { get; set; } [ConcurrencyCheck] [Required] public int LockVersion { get; internal set; } } public abstract class BaseEntityTest2 : BaseEntityTest { [Required] public string Name { get; set; } public string Description { get; set; } } public abstract class BaseEntityTest3: BaseEntityTest2 { [Required] public DateTime FromDate { get; set; } public DateTime ThruDate { get; set; } } public class A: BaseEntityTest3{ public String Test { get; set; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload