本文介绍了什么是实体框架上下文复杂类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 现在我学习了很多关于从Pluralsight影片实体框架,所以请原谅我的问题可能看起来newbish但我不明白什么复杂类型是为什么我需要他们。 我知道我必须通过注解或类似这样的流畅API的东西把它们映射: modelBuilder.ComplexType< blubb>(); 也许有人会阐述复杂类型的不用我? 解决方案 假设你有一个课程在一类的实体,该实体地点,日期及时间的简单属性,但你找到你想要的抽象的,这样其他实体可以使用相同的模型。所以,你可以创建一个复杂类型,包含天,地点和时间给它一个名字:ComplexType1。现在,其他实体可以仅仅通过在模型定义声明ComplexType1使用这种类型,而不是单个标量的属性。 Right now I am learning a lot about the Entity Framework from Videos on Pluralsight, so excuse my Question which might look newbish but I can not understand what Complex Types are or why I would need them.I do know that I have to map them via Annotations or Fluent Api something like this:modelBuilder.ComplexType<blubb>();Maybe someone could elaborate the need of Complex Types for me? 解决方案 Assume you have an entity for Courses in a class, that entity has scalar properties of Location, Days and Time, but you find you want to abstract that so that other entities can use the same model. So you can create a complex type that contains Days, Location and Time give it a name: ComplexType1. Now other entities can use this type rather than individual scalar properties just by declaring ComplexType1 in the model definition. 这篇关于什么是实体框架上下文复杂类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-20 20:23