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

Code First: Implement inheritance support #1704

Closed
8 tasks done
anpete opened this issue Feb 25, 2015 · 4 comments
Closed
8 tasks done

Code First: Implement inheritance support #1704

anpete opened this issue Feb 25, 2015 · 4 comments
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-enhancement
Milestone

Comments

@anpete
Copy link
Contributor

anpete commented Feb 25, 2015

  • APIs for configuring base type
  • Base type discovery convention
  • Support for referencing inherited entity type members
  • Support for ignoring discovered base type
  • Support for ignoring inherited properties
  • APIs for relational discriminator annotations
  • Discriminator introduction convention (readonly by default)
  • Relational model validation rule to ensure correct inheritance mapping
@rowanmiller rowanmiller added this to the 7.0.0 milestone Feb 27, 2015
@divega divega assigned smitpatel and unassigned AndriySvyryd Apr 21, 2015
@AndriySvyryd AndriySvyryd changed the title Inheritance: Implement Code First support Code First: Implement inheritance support Jul 7, 2015
@bricelam
Copy link
Contributor

@AndriySvyryd Two questions:

  1. Will Code First take care uniquifying/collapsing properties in the hierarchy? For example, what would happen to the Name properties:

    class Person
    {
    }
    
    class Student : Person
    {
        public string Name { get; set; }
    }
    
    class Teacher : Person
    {
        public string Name { get; set; }
    }
    
  2. Do you also intend to also update CSharpModelGenerator to serialize inheritance metadata in model snapshots?

@AndriySvyryd
Copy link
Member

@bricelam

  1. Depends. When using a ModelBuilder with just the core conventions the EntityTypes for Student and Teacher each will have a Name property, while the one for Person will have none.
    When also using the relational conventions the TPH convention would create a discriminator shadow property and uniquify all the column names that would end up mapped to Persons table. In this case it will result in columns Name, Name1 and Discriminator named deterministically.
  2. No, that is not part of this issue.

@bricelam
Copy link
Contributor

Sounds good. Thanks.

AndriySvyryd added a commit that referenced this issue Jul 15, 2015
Adjust the ModelBuilder logic to account for base types
Discover abstract CLR types

Part of #1704
AndriySvyryd added a commit that referenced this issue Jul 15, 2015
Adjust the ModelBuilder logic to account for base types
Discover abstract CLR types

Part of #1704
AndriySvyryd added a commit that referenced this issue Jul 15, 2015
Adjust the ModelBuilder logic to account for base types
Discover abstract CLR types

Part of #1704
AndriySvyryd added a commit that referenced this issue Jul 17, 2015
Adjust the ModelBuilder logic to account for base types
Discover abstract CLR types

Part of #1704
AndriySvyryd added a commit that referenced this issue Aug 13, 2015
Add API for setting annotations on internal builders that returns success status

Part of #1704
AndriySvyryd added a commit that referenced this issue Aug 13, 2015
AndriySvyryd added a commit that referenced this issue Aug 15, 2015
@AndriySvyryd
Copy link
Member

Discriminator API:

// If it's a string we just keep using type name for values
modelBuilder.Entity<Plant>().Discriminator<string>("Type_Of_Entity");
modelBuilder.Entity<Plant>().Discriminator(p => p.TypeOfEntity);

modelBuilder.Entity<Rose>().Discriminator(p => p.Genus).Value("Rose");
modelBuilder.Entity<Daisy>().Discriminator(p => p.Genus).Value("Daisy");

modelBuilder.Entity<Plant>().Discriminator(p => p.Genus);
modelBuilder.Entity<Rose>().Discriminator().Value("Rose");
modelBuilder.Entity<Daisy>().Discriminator().Value("Daisy");

// plus support for typeof() overloads
modelBuilder.Entity<Plant>().Discriminator(p => p.Genus)
    .Value<Rose>(PlantGenus.Rose)
    .Value<Daisy>(PlantGenus.Daisy);

@rowanmiller rowanmiller added this to the 7.0.0-rc1 milestone Sep 17, 2015
@rowanmiller rowanmiller removed this from the 7.0.0 milestone Sep 17, 2015
AndriySvyryd added a commit that referenced this issue Sep 25, 2015
Add OnNavigationRemoved to allow RelationshipDiscoveryConvention use the navigations that have been freed
Relationship configuration that conflicts with previous configuration will now override it instead of throwing

Part of #1704
Fixes #2987, #3195
AndriySvyryd added a commit that referenced this issue Sep 25, 2015
Add OnNavigationRemoved to allow RelationshipDiscoveryConvention use the navigations that have been freed
Relationship configuration that conflicts with previous configuration will now override it instead of throwing

Part of #1704
Fixes #2987, #3195
AndriySvyryd added a commit that referenced this issue Sep 28, 2015
Add OnNavigationRemoved to allow RelationshipDiscoveryConvention use the navigations that have been freed
Relationship configuration that conflicts with previous configuration will now override it instead of throwing

Part of #1704
Fixes #2987
AndriySvyryd added a commit that referenced this issue Oct 15, 2015
… in the model using the associated CLR type information

Adjust conventions to correctly handle inheritance
Allow setting the base type to null
Move non-shadow property validation to Property

Fixes #1704
AndriySvyryd added a commit that referenced this issue Oct 16, 2015
… in the model using the associated CLR type information

Adjust conventions to correctly handle inheritance
Allow setting the base type to null
Move non-shadow property validation to Property

Fixes #1704
AndriySvyryd added a commit that referenced this issue Oct 17, 2015
AndriySvyryd added a commit that referenced this issue Oct 19, 2015
AndriySvyryd added a commit that referenced this issue Oct 19, 2015
AndriySvyryd added a commit that referenced this issue Oct 22, 2015
… in the model using the associated CLR type information

Adjust conventions to correctly handle inheritance
Allow setting the base type to null
Move non-shadow property validation to Property

Fixes #1704
AndriySvyryd added a commit that referenced this issue Oct 22, 2015
… in the model using the associated CLR type information

Adjust conventions to correctly handle inheritance
Allow setting the base type to null
Move non-shadow property validation to Property

Fixes #1704
@AndriySvyryd AndriySvyryd removed their assignment Jun 6, 2018
@ajcvickers ajcvickers added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Oct 15, 2022
@ajcvickers ajcvickers modified the milestones: 1.0.0-rc1, 1.0.0 Oct 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-enhancement
Projects
None yet
Development

No branches or pull requests

7 participants