Entity Framework 4.0, PoCo & Navigation Properties for Search Tables


I have the following Models

int Id
string Name

int Id
string Name
DeltaDirectionType DeltaDirectionType
Double Value

int Id
DateTime BusinessDate
IList<Delta> deltas

So DeltaDirectionType is a lookup table, Trade holds a collection of Deltas

In the database it is implemented as follows

Id int
Name varchar(max)

Id int
Name varchar(max)
DeltaDirectionType_Id int
Trade_Id int
Value float

Id int
BusinessDate DateTime
Delta_Id int

When I generate the model from code for the Edmx file, and (un check the foreign keys) as my model does not have properties for these. I am having problem with the navigation properties. Something like this in nHibernate would be a simple one to many mapping for the DeltaDirectionType and Delta and a many to many for Delta and Trades however, how do I firstly get it to recognise that DeltaDirectionType is a lookup and secondly get the Icollection to work for me.

I am struggling with this, Entity Framework does not make it easy for you. I have tried the usual, delete the navigation property that EF puts in for you on one side, but then you get some mapping fragments errors, properties not mapped etc.

Please help or point in the right direction.

Lookup tables are real life problems, not sure why it is so hard withing EF to implement.

Any help much appreciated


You must either create foreign keys or navigation properties in the model to navigate the relationship.

Navigation properties can be defined as one-way, ie from the deltas table to the look-up table. A one-way navigation like this would add the appropriate property to the delta's object but not to the looup table