区分大小写,首先使用实体​​框架代码

时间:2018-06-29 12:05:38

标签: c# entity-framework entity-framework-6 code-first

我使用Entity Framework CodeFirst创建数据库。我看了其他问题,但其中任何一个都不是特别的答案。我尝试将这两个KEY保存为表的不同行。

12E60AED-7491-49B3-8006-78ECEA63B376 12e60aed-7491-49b3-8006-78ecea63b376

这是我的属性类:

  @HostListener('window:resize', ['$event'])
  onResize(event) {
      this.myGrid.updatebounddata();
      console.log(1);
      event.target.innerWidth;
  }

这是我的数据库模型:

[AttributeUsage(AttributeTargets.Property, AllowMultiple = true)]
    public class CaseSensitive : Attribute
    {
            public CaseSensitive()
            {
                IsEnabled = true;
            }
            public bool IsEnabled { get; set; }
    }

这是entityContex:

[Table("StandardBusinessDocument", Schema = "EFatura")]
    public class StandardBusinessDocument{
        [Key]
        [Column( TypeName= "varchar" , Order =0), MaxLength(36) ]
        [CaseSensitive]
        public string StandardBusinessDocumentGuid { get; set; }

        [Key]
        [Column(TypeName = "bit", Order = 1)]
        public Boolean StandardBusinessDocumentType { get; set; }

        [Column(TypeName = "varchar"), MaxLength(4)]
        public string Code{ get; set; }
}

但是,当我从tableDesigner-Collat​​ion中查看caseSensitive时,CaseSensitive被禁用了。我该怎么办?

1 个答案:

答案 0 :(得分:0)

我找到答案。我在[Key]之后编写CaseSensitive,然后完成这项工作。我不知道如何..:

[Key]
[CaseSensitive]
[Column( TypeName= "varchar" , Order =0), MaxLength(36) ]
public string StandardBusinessDocumentGuid { get; set; }