Skip to content

Allow specifying different column names per table in TPT, TPC or entity splitting #19811

@AndriySvyryd

Description

@AndriySvyryd

E.g. int Id could be mapped to int Id in People and to string CustomerId in Customers

TPC:

    modelBuilder.Entity<Person>().ToTable("People")
        .InheritPropertyMapping(false);  
    modelBuilder.Entity<Customer>().ToTable("Customers", t =>
        {
            t.Property(c => c.Id).HasColumnName("CustomerId");
        });

Entity splitting:

    modelBuilder.Entity<Customer>(cb =>
    {
        cb.ToTable("Customers");
        cb.SplitToTable("CustomerDetails", t =>
        {
            t.Property(c => c.Id).HasColumnName("CustomerId");
        })
    };

Also allow to map a base property to the derived table in TPT

TPT:

    modelBuilder.Entity<Person>().ToTable("People");  
    modelBuilder.Entity<Customer>().ToTable("Customers", t =>
        {
            t.Property(c => c.Id).HasColumnName("CustomerId");
        });

Related: #17270 (comment)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions