繁体   English   中英

任何人使用实体框架*嗯*?

[英]Anyone using the Entity Framework *Well*?

有没有人真正发布了一个实体框架项目,该项目将O / R映射到与数据存储区中的表完全不同的概念类中?

我的意思是将结点(M:M)表折叠到其他实体中以形成业务域中存在但在数据存储区中组织为多个表的 概念类。 我在MSDN上看到的所有示例几乎没有使用继承,将联结表折叠到其他实体,或将查找表折叠到实体中。

我很想听到或看到以下示例,它们支持您通常希望在业务对象上执行的所有CRUD操作:

  1. 车辆表和颜色表。 颜色可以出现在许多车辆中(1:M)。 它们构成了具有属性Color的概念类UsedCar。

  2. Doctor,DoctorPatients和Patients表(形成多对多)。 医生有很多患者,患者可以有很多医生(M:M)。 绘制出两个概念类Doctor(具有患者集合)和患者(具有Doctors集合)。

有人在实体框架中使用CSDL和SSDL看到/完成了这个吗? 如果CSDL没有按行动映射到任何东西,那么CSDL就没有用!

我试图在现有项目上使用Entity Framework(约60个表,3个继承),只是为了看看它的全部内容。 我的经验归结为:

设计师的表面是kludgy。 映射不直观,有人必须认为同时打开多个工具窗口是可以接受的。 手动创建一个对象并映射正确的字段花了很长时间 - 然后从代码中与它交谈仍然很奇怪。 虽然有一些处理数据库通信的东西是必不可少的,但我觉得将控制权移交给EF远比手工操作更具斗争性

有时,在重新启动Visual Studio之前,设计器才会加载。 我确定这只是一个错误,但重启VS很烦人。

你的所有工作都以一个文件结束,我讨厌合并多个开发者版本。

结果SQL(通过Profiler观看)不是很好。 我并没有真正深入研究为什么,但是你会被迫在第一次尝试时写下更糟糕的东西。

实体框架 - 不信任投票

这就是我要说的全部......

你的意思是这样的?

<edmx:ConceptualModels>
  <Schema xmlns="http://schemas.microsoft.com/ado/2006/04/edm" Namespace="Model1" Alias="Self">
    <EntityContainer Name="Model1Container" >
      <EntitySet Name="ColorSet" EntityType="Model1.Color" />
      <EntitySet Name="DoctorSet" EntityType="Model1.Doctor" />
      <EntitySet Name="PatientSet" EntityType="Model1.Patient" />
      <EntitySet Name="UsedCarSet" EntityType="Model1.UsedCar" />
      <AssociationSet Name="Vehicle_Color" Association="Model1.Vehicle_Color">
        <End Role="Colors" EntitySet="ColorSet" />
        <End Role="Vehicles" EntitySet="UsedCarSet" /></AssociationSet>
      <AssociationSet Name="DoctorPatient" Association="Model1.DoctorPatient">
        <End Role="Doctor" EntitySet="DoctorSet" />
        <End Role="Patient" EntitySet="PatientSet" /></AssociationSet>
      </EntityContainer>
    <EntityType Name="Color">
      <Key>
        <PropertyRef Name="ColorID" /></Key>
      <Property Name="ColorID" Type="Int32" Nullable="false" />
      <NavigationProperty Name="Vehicles" Relationship="Model1.Vehicle_Color" FromRole="Colors" ToRole="Vehicles" /></EntityType>
    <EntityType Name="Doctor">
      <Key>
        <PropertyRef Name="DoctorID" /></Key>
      <Property Name="DoctorID" Type="Int32" Nullable="false" />
      <NavigationProperty Name="Patients" Relationship="Model1.DoctorPatient" FromRole="Doctor" ToRole="Patient" /></EntityType>
    <EntityType Name="Patient">
      <Key>
        <PropertyRef Name="PatientID" /></Key>
      <Property Name="PatientID" Type="Int32" Nullable="false" />
      <NavigationProperty Name="Doctors" Relationship="Model1.DoctorPatient" FromRole="Patient" ToRole="Doctor" />
      </EntityType>
    <EntityType Name="UsedCar">
      <Key>
        <PropertyRef Name="VehicleID" /></Key>
      <Property Name="VehicleID" Type="Int32" Nullable="false" />
      <NavigationProperty Name="Color" Relationship="Model1.Vehicle_Color" FromRole="Vehicles" ToRole="Colors" /></EntityType>
    <Association Name="Vehicle_Color">
      <End Type="Model1.Color" Role="Colors" Multiplicity="1" />
      <End Type="Model1.UsedCar" Role="Vehicles" Multiplicity="*" /></Association>
    <Association Name="DoctorPatient">
      <End Type="Model1.Doctor" Role="Doctor" Multiplicity="*" />
      <End Type="Model1.Patient" Role="Patient" Multiplicity="*" /></Association>
    </Schema>
</edmx:ConceptualModels>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM