Hi,
I'm reading about the Entity Framework 4.0 and I was wondering why should I create a complex type and not a new Entity (Table) and a relation between them?
Thanks, Ronny
Hi,
I'm reading about the Entity Framework 4.0 and I was wondering why should I create a complex type and not a new Entity (Table) and a relation between them?
Thanks, Ronny
The perfect example is an address. Using a complex type for an address is much easier to deal with than a new entity. With complex types you do not have to deal with the Primary Key. Think about accessing an address how many common types of entities would have an address (Business Units, People, Places). Imagine populating many peoples addresses and needing to set a key for each one. With complex types you simply access the internal properties of they type and your done. Here is an MSDN link of an example. http://msdn.microsoft.com/en-us/library/bb738613.aspx
Hi, I find that Address is often an example used as an obvious Complex Type. However I would argue that - should you EVER want you application to support international addresses in future (e.g. UK, US, French) - then you may well regret that decision!