Entity Framework Complex Type vs Creating new Entity

后端 未结 3 1504
情歌与酒
情歌与酒 2021-02-05 02:45

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?

3条回答
  •  太阳男子
    2021-02-05 03:20

    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 you're done. Here is an MSDN link of an example. http://msdn.microsoft.com/en-us/library/bb738613.aspx

提交回复
热议问题