views:

25

answers:

1

I have these tables;

Customer
- CustomerID (primary key)
- Name

Car
- CarID (primary key)
- Model

Customer_Car_Map (composite primary key CustomerID and CarID)
- CustomerID (foreign key to Customer.CustomerID)
- CarID (foreign key to Car.CarID)

When I generate the models from the database using EF4, it generates classes for all tables except for the _Map tables. For these it seems to add an EdmRelationshipAttribute, but not separate class.

How would I create and save a new Customer_Car_Map?

A: 

If the Entity Framework does its job correctly, you shouldn't need a class for the mapping tables.

Entity Framework 4 supports many to many relationships. It will generate Members on either of the Entities representing the two sides of the mapping tables. You will use the Entities to add relationships and Entity Framework will utilize the mapping table behind the scenes.

If those facilities aren't enough to get the job done, I would question why you need access to such low level data in your application.

Justin Niessner