Creating string index with Code first

后端 未结 2 1706
深忆病人
深忆病人 2020-12-08 13:38

I\'m using Entity Framework 6.1 code-first and my domain model is below.

class Item
{
    [Index]
    public string CreatedBy { set; get; }
} 
2条回答
  •  没有蜡笔的小新
    2020-12-08 14:02

    Usually you get this error when you use a VARCHAR(Max) try using:

    [Column(TypeName = "VARCHAR")]
    [StringLength(n)]
    [Index]
    public string CreatedBy { set; get; }
    

    where n is between 1 and 450.

提交回复
热议问题