3

A blog entry I read seems to indicate it's ok for value objects to reference entities in domain driven design, and the follow-up explains how to do this in NHibernate.

I would like to do the same thing using Entity Framework 4.1: specifically, have a complex type reference another entity. As an example consider this: I have an entity, let's say, Invoice that has a Total property of type Currency. Currency is a complex type containing a property of type decimal called Value and a Unit property of type CurrencyUnit. CurrencyUnit is a "reference data entity". That is, CurrencyUnit in this particular domain is an entity, not a value object itself.

Now while possibly "allowed" in DDD, it's not my preference; I don't want to debate the merits. I'm interested in learning if there is a code-first solution in EF to handle this scenario. I can't seem to find anything, which is odd since complex types map to their entity's containing table, which can of course have foreign key references.

Kit
  • 20,354
  • 4
  • 60
  • 103

1 Answers1

1

Crud (no pun intended) I just found this question whose answer indicates its simply not implemented in EF 4.1: EF4 complex type with navigation property (is it possible) or alternatives?

Community
  • 1
  • 1
Kit
  • 20,354
  • 4
  • 60
  • 103