gigi
gigi

Reputation: 3946

Entity Framework 4 many to many relationship issue

Considering this database: enter image description here

This is what EF generates: enter image description here

I think that HeroesItem class, is useless, and there should be a navigation property Items on Hero class and a navigation property Heroes on Item class.

I saw this can be done easily with code first, but how to get it done using database first?

Upvotes: 0

Views: 69

Answers (1)

Ladislav Mrnka
Ladislav Mrnka

Reputation: 364409

It can be done only if your HeroesItems table does not contain Id column and instead uses IdHero and IdItem as composite primary key. Once you add any additional column to junction table you must map it as entity to have control over that column.

Upvotes: 1

Related Questions