gpt4 book ai didi

asp.net-mvc - asp .net MVC 应用程序无法识别 [Key, Column(Order = 0)] 属性

转载 作者:行者123 更新时间:2023-12-01 12:47:49 25 4
gpt4 key购买 nike

using System.ComponentModel.DataAnnotations;    

public class UserArmy
{
[Key, Column(Order = 1)]
public Guid UserId { get; set; }
[Key, Column(Order = 2)]
public int UnitId { get; set; }
public int Quantity { get; set; }
}

这是我的模型类。我正在使用 Entity Framework,Code First 方法。可以识别 [Key] 属性,但不能识别 Column(Order=x)。

我是否遗漏了一些需要包含的内容?

谢谢:)

最佳答案

您必须添加以下命名空间:

using System.ComponentModel.DataAnnotations.Schema;

http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.schema.aspx

关于asp.net-mvc - asp .net MVC 应用程序无法识别 [Key, Column(Order = 0)] 属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14306951/

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