【发布时间】:2011-08-24 00:40:11
【问题描述】:
您好,我正在尝试为我的 MVC3 应用程序定义 CatergoryModel。我想知道我该如何设置 ID 自动递增。
public class Category
{
[Required]
public int Id { get; set; }
[Required]
public string Name { get; set; }
[Required]
public string Type { get; set; }
[Required]
public string Title { get; set; }
[Required]
public string MetaKey { get; set; }
[Required]
public string MetaKeyDesc { get; set; }
[Required]
public DateTime CreatedAt { get; set; }
[Required]
public DateTime UpdatedAt { get; set; }
public int CategoryId { get; set; }
}
【问题讨论】:
-
这与 MVC 无关。你在谈论
IDENTITY,这是一个数据库问题。
标签: asp.net-mvc-3 model asp.net-mvc-scaffolding