【问题标题】:Entity Framework Code First 6.0: is there any annotations to add index to a column(s)Entity Framework Code First 6.0:是否有任何注释可以为列添加索引
【发布时间】:2013-11-16 16:18:20
【问题描述】:

我是第一次使用 EF6。有这样一张桌子:

public class DBBlog
{
     public int Id { get; set; }
     public string Title { get; set; }  //<-- need to be indexed
}

请指教

【问题讨论】:

标签: c# entity-framework indexing


【解决方案1】:

该功能是为 EF 6.1 添加的,并且已在夜间构建中可用。欲了解更多信息:

https://entityframework.codeplex.com/workitem/57

【讨论】:

    【解决方案2】:

    不幸的是,EF 中还没有 DataAnnotion 来创建索引。当您使用迁移时,您可以调整创建的迁移以手动添加索引。

    【讨论】:

      猜你喜欢
      • 2012-01-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-06
      • 2011-06-18
      • 1970-01-01
      • 2012-01-24
      相关资源
      最近更新 更多