Skip to content
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

TPH with re-used column names not supported #745

Open
Bouke opened this issue Jan 28, 2022 · 2 comments
Open

TPH with re-used column names not supported #745

Bouke opened this issue Jan 28, 2022 · 2 comments
Labels

Comments

@Bouke
Copy link

Bouke commented Jan 28, 2022

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

@borisdj
Copy link
Owner

borisdj commented Jan 28, 2022

Not currently supported.

@andyguerra
Copy link

This could be a very nice feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants