jjzjj

IndexAttribute

全部标签

c# - ASP.NET Core Entity Framework Core 找不到 IndexAttribute

在执行“dotnetrun”后,我在我的Mac上的IDE和控制台窗口中收到来自VisualStudioCode的以下信息:Thetypeornamespacename'IndexAttribute'couldnotbefound我有一个名为Story的类,我想使用它通过CodeFirst生成数据库。此类有一个标有KeyAttribute的主键和标有MaxLengthAttribute的Author字符串,因此它们都有效(使用System.ComponentModel.DataAnnotations)。另外两个字段DateTimeDate和boolIsPublished应用了IndexA

c# - 在 Entity Framework 6.1(非 Core)中,如何使用 IndexAttribute 来定义聚簇索引?

EntityFramework6.1(代码优先)增加了通过IndexAttribute添加索引的可能性。.该属性采用一个参数来指定索引是聚簇的还是非聚簇的。同时,据我所知,EntityFramework要求每个实体都有一个主键(用KeyAttribute注释),并且该主键始终创建为集群键。p>因此,一旦我申请IndexAttribute与IsClustered=true,我得到一个错误,因为,由于键,已经有一个聚集索引。那么,如何使用IndexAttribute创建一个不是主键的聚簇索引??是IsClusteredIndexAttribute的属性(property)可以用吗?(关于更