1
我有這個類鏈接到一個視圖在SQL Server:映射類返回列表 - 實體框架
[Table("V_Clients")]
public class Client
{
[Key]
public int ClientId { get; set; }
public short BranchId { get; set; }
public string CorporateName { get; set; }
public string TIN { get; set; }
public string Address { get; set; }
public string Phone { get; set; }
public string Id { get; set; }//NroCi
public short CityId { get; set; }
public short ZoneId { get; set; }
public short SubZoneId { get; set; }
public short VendorId { get; set; }
public short PriceListId { get; set; }
public short CollectorId { get; set; }
[ForeignKey("BranchId")]
public virtual Branch Branch { get; set; }
[ForeignKey("CityId")]
public virtual City City { get; set; }
[ForeignKey("ZoneId")]
public virtual Zone Zone { get; set; }
[ForeignKey("SubZoneId")]
public virtual SubZone SubZone { get; set; }
[ForeignKey("VendorId")]
public virtual Vendor Vendor { get; set; }
[ForeignKey("PriceListId")]
public virtual PriceList PriceLists {get;set;}
[ForeignKey("CollectorId")]
public virtual Collector Collector { get; set; }
}
但是當我嘗試做這樣的它的列表:
public ActionResult Index()
{
var clients = db.Clients.Include(c => c.Branch).Include(c => c.City).Include(c => c.Zone).Include(c => c.SubZone).Include(c => c.Vendor).Include(c => c.PriceLists).Include(c => c.Collector);
return View(clients.ToList());
}
沒有任何反應。難道是因爲這種關係嗎?
注意:所有課程均與視圖相關聯,並且與其他課程(除我的Client
課程除外)無關。
我已經試過幾乎所有的東西和我最終的結論是:「這不是一個享有健康的地圖實體框架」。 已解決。 – Hugo