EFCore.BulkExtensions icon indicating copy to clipboard operation
EFCore.BulkExtensions copied to clipboard

TPH with re-used column names not supported

Open Bouke opened this issue 3 years ago • 2 comments

I have a TPH structure similar to the following where an inheriting class adds a property with the same name / column mapping as another inheriting class.

abstract class Mamal
{
}

class Person : Mamal
{
    public string Name { get; set; }
    internal new class Configuration : IEntityTypeConfiguration<Person>
    {
        public void Configure(EntityTypeBuilder<Person> builder)
        {
            builder.Property(x => x.Name).HasColumnName(nameof(Name));
        }
    }
}

class Pet : Mamal
{
    public string Name { get; set; }
    internal new class Configuration : IEntityTypeConfiguration<Pet>
    {
        public void Configure(EntityTypeBuilder<Pet> builder)
        {
            builder.Property(x => x.Name).HasColumnName(nameof(Name));
        }
    }
}

Using BulkInsert this yields the following exception:

System.ArgumentException: An item with the same key has already been added. Key: Name

Bouke avatar Jan 28 '22 08:01 Bouke

Not currently supported.

borisdj avatar Jan 28 '22 14:01 borisdj

This could be a very nice feature.

andyguerra avatar Mar 20 '23 19:03 andyguerra