gpt4 book ai didi

asp.net-mvc-3 - 如何自动递增数据类型模型

转载 作者:行者123 更新时间:2023-12-02 08:29:26 25 4
gpt4 key购买 nike

您好,我正在尝试为我的 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; }

}

最佳答案

只需在 Id 字段之前添加 [Key] 注释即可。

关于asp.net-mvc-3 - 如何自动递增数据类型模型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7169180/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com