gpt4 book ai didi

c# - 如何使用 Entity Framework 6.1.1 中的 [Index] 属性和 Code First

转载 作者:太空狗 更新时间:2023-10-29 22:18:57 24 4
gpt4 key购买 nike

我首先使用实体​​框架 6.1.1 和代码。 EF 6.1 应该添加了对 Index attribute 的支持, 但编辑器自动完成或编译器都不接受 [Index] 属性,例如:

[Index]
public DateTime TimeOfSale { get; set; }

所有项目引用都指向 EF 6.1.1 的 DLL。

我还在运行 SQL Server Compact Edition 4.0。

如何启用新的 [Index] 属性?

最佳答案

KeyAttributeSystem.ComponentModel.DataAnnotations 命名空间中,而 IndexAttribute 类在 System.ComponentModel 中。 DataAnnotations.Schema 命名空间。您可能缺少以下 using 语句:

using System.ComponentModel.DataAnnotations.Schema;

关于c# - 如何使用 Entity Framework 6.1.1 中的 [Index] 属性和 Code First,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26043565/

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