-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inheritance hierarchies that include owned entity types are not supported #14451
Comments
@sbsw This means that owned entity types cannot themselves be in an inheritance hierarchy. It does not mean that entity types that are part of an inheritance hierarchy cannot have owned types. For example, this is fine: public class Blog
{
public int Id { get; set; }
}
public class GoodBlog : Blog
{
public Address HomeAddress { get; set; }
public Address WorkAddress { get; set; }
}
public class Address
{
public string Street { get; set; }
public string Zip { get; set; }
} protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Blog>();
modelBuilder.Entity<GoodBlog>(b =>
{
b.OwnsOne(e => e.HomeAddress);
b.OwnsOne(e => e.WorkAddress);
});
} For the not supported case, see #9630 |
Oh. In that case, I seem to have stumbled across a bug. I’ll see if I can re-create the issue in a simple example, and open a new issue on that.
I will also put in a documentation issue to clarify the inheritance limitation.
Bob
Sent from my iPhone. Bizarre, humorous, or nonsensical autocorrects are a "feature".
… On Jan 17, 2019, at 2:52 PM, Arthur Vickers ***@***.***> wrote:
@sbsw This means that owned entity types cannot themselves be in an inheritance hierarchy. It does not mean that entity types that are part of an inheritance hierarchy cannot have owned types. For example, this is fine:
public class Blog
{
public int Id { get; set; }
}
public class GoodBlog : Blog
{
public Address HomeAddress { get; set; }
public Address WorkAddress { get; set; }
}
public class Address
{
public string Street { get; set; }
public string Zip { get; set; }
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Blog>();
modelBuilder.Entity<GoodBlog>(b =>
{
b.OwnsOne(e => e.HomeAddress);
b.OwnsOne(e => e.WorkAddress);
});
}
For the not supported case, see #9630
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Sorry if I'm commenting on this closed issue in error, but I seem to be having the following related issue to inheritance and owned entity types. Given the following: [Owned]
public class FileGuid
{
public Guid Guid { get; set; }
public string FileExtension { get; set; }
}
public abstract class Asset
{
public Guid Guid { get; set; }
public string Name { get; set; }
}
public class MaterialAsset : Asset
{
public int Color { get; set; }
public bool Transparent { get; set; }
public float Opacity { get; set; }
public FileGuid TextureAsset { get; set; }
public FileGuid DecalTextureAsset { get; set; }
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Asset>().HasKey(a => a.Guid);
modelBuilder.Entity<MaterialAsset>().HasBaseType<Asset>();
modelBuilder.Entity<MaterialAsset>().OwnsOne(ma => ma.TextureAsset, o =>
{
o.Property(fg => fg.Guid).HasColumnName("TextureAsset_Guid");
o.Property(fg => fg.FileExtension).HasColumnName("TextureAsset_FileExtension");
});
modelBuilder.Entity<MaterialAsset>().OwnsOne(ma => ma.DecalTextureAsset, o =>
{
o.Property(fg => fg.Guid).HasColumnName("DecalTextureAsset_Guid");
o.Property(fg => fg.FileExtension).HasColumnName("DecalTextureAsset_FileExtension");
});
} Gives the following exception:
When I don't use the
This does NOT happen when I rename the
Is this expected behavior or a known limitation? |
The documentation states:
The practical upshot of this is that any class that inherits from
IdentityUser
cannot reliably include an owned type. This is turning out to be a major headache.So, I have two questions:
The text was updated successfully, but these errors were encountered: