【发布时间】:2026-01-12 09:50:01
【问题描述】:
我已经在实体框架中实现了 Table Per Concrete Type 如下
我有 Vehicle 和 OldVehicle 表。 Vehicle 是基础实体,OldVehicle 是派生实体。
我已从派生实体(即 OldVehicle)中删除了所有重叠属性。
现在我尝试从 OldVehicle 中检索数据,如下所示:
CarRentalModelEntities context = new CarRentalModelEntities();
var oldVeh = context.Vehicles.OfType<OldVehicle>();
foreach (var oh in oldVeh)
{
--Some Code Here--
}
我的 OldVehicle 表中有 9 条记录。
【问题讨论】:
-
问题出在哪里?
-
不确定。我没有收到任何错误消息。
-
请显示映射。
标签: c# entity-framework inheritance