So I'm trying to get my head around this for a while now, but I don't seem to succeed. In my application I'm using a generic repository with Entity Framework Core. Hence my Repository always expect that it's accessed from a class who's BaseEntity or has inherited from that certain class. Now I want to implement .Net Core Identity with it. But My User class is inheriting from BaseEntity. But I'd also need it to inherit from Identity in order to make it work I guess. How am I able to still use Identity?
C# only supports single inheritance. You cannot inherit from two different classes. Additionally your Identity user class, must inherit from
IdentityUser. You have no choice in that. As a result, the best you can do is make your user class and the rest of your entity classes implement the same interface, i.e.
IEntity. Then, instead of constraining your generic type as
Of course, this means you will incur a bit of code duplication as you'll have to implement
IEntity separately on both
BaseEntity and your user class. However, that is unavoidable.