Two classes mapping the same table with the Entity Framework

Asked

Viewed 424 times

4

I’m trying to do the entity map two classes to the same table this is possible?

Setting:

Man identity this decoupled (Eduardo Pires' Master) from my domain and the presentation layer in the domain layer I have a class usuario that I would like to represent the table AspNetUsers, but when I refer the class usuario in the context (DBSet<usuario>) and send the migrations update all it shows me the following error:

The entity types 'Usuario' and 'IdentityUser' cannot share table 'AspNetUsers' because they are not in the same type hierarchy or do not have a valid one to one foreign key relationship with matching primary keys between them.

I’ve circled all over, but, I haven’t succeeded, someone can shed some light?

  • What you’re trying to do, it doesn’t work, and the error says that there’s a hierarchy of relationship between them.

  • Opa... Vlw by the speed.... And by chance I can convert the applicationUser to be received by my user class????

  • Also no, what you need to do?

  • 1

    Implement an interface with some specific methods to handle user data.

  • 1

    So, I implemented making direct reference to the context of Identity... I know q is not very elegant but it worked... vlw by the willingness to help...

1 answer

1

is using Identity must not use DbSet<Usuarios>

and yes db.Users.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.