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

Model configuration: Properties not always lifted correctly when using derived classes #6814

Closed
HappyNomad opened this issue Oct 19, 2016 · 2 comments
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Milestone

Comments

@HappyNomad
Copy link

This issue can be reproduced by trying to create a database using this context and model:

public class BloggingContext : DbContext
{
    public BloggingContext( DbContextOptions<BloggingContext> options )
        : base( options ) { }

    public DbSet<A> As { get; set; }
}

public class A
{
    public int ID { get; set; }
    public L M3 { get; set; }
    public IList<PBase> Ls { get; set; }
    public MT M2 { get; set; }
    public M M1 { get; set; }
}

public class C : OT { }

public class MT
{
    public int ID { get; set; }
    public IList<ST> STs { get; set; }
    public IList<OGT> OGs { get; set; }
}

public class M
{
    public int ID { get; set; }
    public IList<S> Ss { get; set; }
}

public class ST : P
{
    public C DC { get; set; }
}

public class OGT : P
{
    public IList<OT> Os { get; set; }
}

public class S
{
    public int ID { get; set; }
    public ST Type { get; set; }
}

public class OT : P { }

public class L
{
    public int ID { get; set; }
    public IList<T> Ts { get; set; }
}

public class T : P
{
    public P P { get; set; }
    public Q F { get; set; }
}

public class P : PBase { }

public class Q : PBase { }

public abstract class PBase
{
    public int ID { get; set; }
    public string Stuff { get; set; }
}

The exception text says, "The type 'OT' cannot have base type 'P' because both types include the properties: ID, Stuff."

@HappyNomad
Copy link
Author

HappyNomad commented Oct 20, 2016

@rowanmiller Thanks for acknowledging this as a bug. Another likely incorrect exception that occurs upon feeding EF-Core my domain model is described in #6792. I've edited my comment there to include a context and model that reproduces the issue. Please note that both of these are blocking issues for me.

AndriySvyryd added a commit that referenced this issue Oct 26, 2016
…e when setting base type.

Properly discover base types when they are added to the model after the derived types.
Improve the exception message for conflicting properties in the new base type.
Don't duplicate unused inherited properties that are being removed when setting a new base type. They will be discovered by conventions if they should be on the entity type.

Fixes #6814
AndriySvyryd added a commit that referenced this issue Oct 26, 2016
…e when setting base type.

Properly discover base types when they are added to the model after the derived types.
Improve the exception message for conflicting properties in the new base type.
Don't duplicate unused inherited properties that are being removed when setting a new base type. They will be discovered by conventions if they should be on the entity type.

Fixes #6814
@AndriySvyryd AndriySvyryd added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Oct 26, 2016
@AndriySvyryd AndriySvyryd removed their assignment Oct 26, 2016
@AndriySvyryd
Copy link
Member

Fixed in b689f18

smitpatel pushed a commit that referenced this issue Nov 8, 2016
…e when setting base type.

Properly discover base types when they are added to the model after the derived types.
Improve the exception message for conflicting properties in the new base type.
Don't duplicate unused inherited properties that are being removed when setting a new base type. They will be discovered by conventions if they should be on the entity type.

Fixes #6814
@ajcvickers ajcvickers changed the title Exception says base and derived classes have same properties, but they don't Model configuration: Properties not always lifted correctly when using derived classes May 9, 2017
@divega divega added closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. and removed closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. labels May 10, 2017
@ajcvickers ajcvickers modified the milestones: 2.0.0-preview1, 2.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-bug
Projects
None yet
Development

No branches or pull requests

5 participants