【发布时间】:2014-03-29 15:38:11
【问题描述】:
我的外键有问题。
错误:类型“mvcCristal.Models.Almacen”的属性“co_art”上的 ForeignKeyAttribute 无效。在依赖类型“mvcCristal.Models.Almacen”上找不到导航属性“Articulo”。 Name 值应该是有效的导航属性名称。
我的班级宣言:
public class Articulo
{
[Required]
public string co_art { get; set; }
public string des_art { get; set; }
public string modelo { get; set; }
public string co_lin { get; set; }
public string co_subl { get; set; }
public string co_cat { get; set; }
public string co_col { get; set; }
[ForeignKey("co_art")]
public ICollection<Almacen> Almacenes { get; set; }
}
public class Almacen
{
[Key, Column(Order = 0)]
public string co_alma { get; set; }
public string des_alm { get; set; }
[Required, ForeignKey("Articulo"), Column(Order = 1)]
public string co_art { get; set; }
public double stock_act { get; set; }
}
有什么帮助吗?谢谢;我是 EF 的新手。
【问题讨论】:
标签: c# entity-framework