【发布时间】:2012-07-03 03:39:48
【问题描述】:
我目前正在开发一个 ASP.Net MVC3 项目。我已经设置好了,所以我的 sql 数据库根据我创建的类创建了它的表,我需要知道是否有办法设置它,以便变量可以为空,例如:
public class Cart
{
[Key]
public int RecordId { get; set; }
public string CartId { get; set; }
public int VideoId { get; set; }
public int CandyId { get; set; }
public int Count { get; set; }
public System.DateTime DateCreated { get; set; }
public virtual Video Video { get; set; }
public virtual Candy Candy { get; set; }
}
有没有办法将 VideoId 和 Candy Id 设置为空?他们现在出现的方式是作为其他表的外键。非常感谢任何和所有帮助。
【问题讨论】:
-
应该
VideoId不是Video表的外键吗?
标签: sql asp.net-mvc-3 null ef-code-first data-annotations