0

I have the 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

RonenIL
  • 273
  • 3
  • 8
  • 17

1 Answers1

0

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 ...).

Jayantha Lal Sirisena
  • 21,216
  • 11
  • 71
  • 92
  • but this is wrong , the relation between Errors and Sites are many-to-many, and i always keep getting mapping error – RonenIL Jul 31 '11 at 08:55
  • if Errors and Sites are many-to-many then no point of keeping site id in the error table. If you have created a many-to-many relationship on Errors and Sites entity framework will add another table in your database to keep siteId and ErrorId for the realationship. And make sure after the mapping you have regenarate your db. If not you wll get a mapping error. – Jayantha Lal Sirisena Jul 31 '11 at 09:48
  • when i create the many-to-many association i always keep get error in mapping the association. that is my problem. since Errors can have many instances of Sites and Sites can have many Errors. – RonenIL Jul 31 '11 at 10:02
  • did you try after removing SiteId in errors table and adding navigation properties? – Jayantha Lal Sirisena Jul 31 '11 at 10:08