我有一个SQL View,首先需要与EF Core Code一起使用。视图看起来像这样(简化):
Select s.Id
a.City
a.State
From Shipment s
Join Address a
On s.AddressId = a.Id
我希望它映射到发货清单视图的类POCO:
public class ShipmentListView
{
[Key]
public int Id { get; set; }
public Address Address { get; set; }
}
public class Address
{
public string City { get; set; }
public string State { get; set; }
}
Db设置:
public virtual DbSet<ShipmentListView> ShipmentListView { get; set; }
如何映射规范化视图,以便可以在POCO Address
的上下文中重用我的ShipmentListView
类>
我有一个SQL View,首先需要与EF Core Code一起使用。视图看起来像这样(简化):选择s.Id a.City a.State ...
您可以使用下面的SQL View映射模型;