I have a program using Entity Framework (EF) Database First in the data access layer. I know that in order for EF to auto-generate the navigation properties of a many to many relationship, the mapping table needs to contain only a composite primary key:
Project
- ProjectId (PK)
- Name
ContentType
- ContentTypeId (PK)
- Name
ProjectContentTypeMapping
- ProjectId (PK)
- ContentTypeId (PK)
In this case everything works fine, and I can access Projects from ContentTypes and the other way around with navigation properties.
However I have a requirement to have extra fields that are particular to the relation between Projects and ContentTypes, and that would be extra columns in the ProjectContentTypeMapping table. Once I add these I loose the navigation properties, and EF shows the mapping table in the designer.
Is there any way I can manually configure the mapping between these two tables in EF (Database First)? Alternatively, how can I represent this? I was thinking of maybe having an extra "metadata" table with a FK to the mapping table, but it looks "hacky" to me...
Thanks