views:

381

answers:

2

I'm using VS2010 Beta 2, I have a Complex Type called Address with the following properties:

  • Street
  • City
  • CountryId

I have a Country Entity defined in my Model, but I can't seem to find a way to add a reference (Navigation Property) from the CountryId property of my Complex Type to the Id property of my Country entity.

I'm I going about this the wrong way or is this something that I can't do with the designer??...

Another option I have is just creating an Address entity, but it just doesn't sound right to me.

+1  A: 

Ok,

It seems like the current version of the Entity Framework doesn't support a Navigation Property or foreign key within a Complex Type.

The other sensible option is to create a separate Address Entity, which will have all of the foreign keys it needs, and then create Navigation Properties within all my other entities.

hminaya
+1  A: 

No, you can't do this, because it goes against the idea of what complex types and navigation properties are. Complex types have value semantics, rather than reference identity. Navigation properties are first-class entities and have reference semantics. Therefore, they cannot be part of a complex type. As it seems you've discovered, the solution is to partition the parts with value semantics into the complex type, and add it to an entity containing the navigation properties you require.

Craig Stuntz