I create database with Entity Framework CodeFirst. I look other questions but any of them has not spesific answer.I try to save this two KEY's as a different rows to my table.:
12E60AED-7491-49B3-8006-78ECEA63B376 12e60aed-7491-49b3-8006-78ecea63b376
This is my class for attribute:
[AttributeUsage(AttributeTargets.Property, AllowMultiple = true)]
public class CaseSensitive : Attribute
{
public CaseSensitive()
{
IsEnabled = true;
}
public bool IsEnabled { get; set; }
}
This is my db model:
[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; }
}
An this is entityContex:
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Conventions.Add
(new AttributeToColumnAnnotationConvention<CaseSensitive, bool>
("CaseSensitive", (property, attributes) => attributes.Single().IsEnabled));
}
But it doesnt work, when I look caseSensitive from tableDesigner-Collation CaseSensitive is disabled. How can I work it?
I find answer. I write CaseSensitive after [Key] and this work. I don't know how..:
[Key]
[CaseSensitive]
[Column( TypeName= "varchar" , Order =0), MaxLength(36) ]
public string StandardBusinessDocumentGuid { get; set; }