开发者

Defining Many-to-Many Association in Entity Framework

I have th开发者_如何学Ce following tables in my edmx :

Errors

Id, Description, solved, officeId, siteId

Sites

id, location, name , officeId

Offices

officeId, officeName

the mapping between offices to sites are 1-to-many(offices can have many instances of sites).

i want to create many-to-many association from Errors to Sites so i can access Sites properties directly. I always keeps error in mapping. can someone guide me how to do it right?

thanks in advance


You don't need to ad foreign key properties like officeId in Erros table in the edmx. Instead of adding those add associations among entities(Right click on your entity and choose addnew-> associatoin ). When you are adding associations you can define the relationship (one to many,may to many ...).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜