I've created an edmx for my database. In it Entity framework removed a table and instead created an association between two tables because it matches a column name with the primary key in the other table.
I do not want that as there is no real association between those tables. How can I remove that association and get a class for the middle table instead?
Example:
SomeTable
- Id int pk
MiddleTable
- SomeTableId int fk
- SomeCode int
OtherTable
- SomeCode int pk
It's the MiddleTable
which do not get a class.
OtherTable
.MiddleTable
.OtherTable
.When I do this with a similar model I end up with an association between
SomeTable
andMiddleTable
and an unassociatedOtherTable
. Now you can add/remove associations manually as you wish.It's normal EF behavior not to create a class for the middle table. This is a so-called many to many association between
SomeTable
andOtherTable
which can be modelled by two collection properties:SomeTable.OtherTables
OtherTable.SomeTables
The middle table, the junction table, is not really necessary.
It's a bit surprising to me that you say that there is no association between the two tables although, apparently, in the database there are foreign keys. Technically, it is a many to many association.