Search code examples
ef-code-first

Add List of EntityB as Property to EntityA that has no relation to EntityB


I have a database first ef core project

There is an Entity 'Application' and an Entity 'Roles' without a relation

There is an Entity 'UserRoles' that has all the relations between 'Application' and 'Roles' and 'Users'

I can load all the referenced UserRoles in the Application Entity with

context.Applications.Include(inc => inc.UserRoles)

But can I load all existing Roles into the 'Application' Entity - and if, how is this called? Or do I have to create an additional Entity? (It's needed for a Web-Navigation Control)


Solution

  • Nevermind, I changed the Database Model and added a Relation between Application and Role