【发布时间】:2018-06-29 12:05:38
【问题描述】:
我使用 Entity Framework CodeFirst 创建数据库。我查看其他问题,但其中任何一个都没有特别的答案。我尝试将这两个 KEY 作为不同的行保存到我的表中。:
12E60AED-7491-49B3-8006-78ECEA63B376 12e60aed-7491-49b3-8006-78ecea63b376
这是我的属性类:
[AttributeUsage(AttributeTargets.Property, AllowMultiple = true)]
public class CaseSensitive : Attribute
{
public CaseSensitive()
{
IsEnabled = true;
}
public bool IsEnabled { get; set; }
}
这是我的数据库模型:
[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; }
}
这是 entityContext:
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Conventions.Add
(new AttributeToColumnAnnotationConvention<CaseSensitive, bool>
("CaseSensitive", (property, attributes) => attributes.Single().IsEnabled));
}
但是当我从 tableDesigner-Collation CaseSensitive 中查看 caseSensitive 时,它不起作用。我该怎么做?
【问题讨论】:
-
CaseSensitive 无法 - 你的意思是启用,禁用吗?
-
@Rafalon 是的,谢谢指正
-
您应该更改 sql 中字段的排序规则。这里有一个链接:stackoverflow.com/questions/33233168/…,此处提供了排序规则列表:zarez.net/?p=1893
标签: c# entity-framework entity-framework-6 code-first