EF Core one-to-many without Foreign Key (FK)

entity-framework entity-framework-core foreign-keys one-to-many

Question

Are there ways to make one-to-many (abstract) relation without using SQL foreign keys?

I know it could be made by joining 2 non-related tables. But is it possible to use EF Core default navigation tools?

1
1
4/5/2018 2:42:40 PM

Popular Answer

I think you want that because you can't add a foreign-key to your entity

So, you can solve that so:

You have a entity

Group

and you want a

List<User>

but your User can't be assigned to one group. So you create a

GroupUser

entity which has a foreign key for the

List<GroupUser>

and a navigation property to the User

This is called a many-to-many relationship

0
4/5/2018 4:48:22 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow