Creo database con Entity Framework CodeFirst. Sembro altre domande ma nessuna di esse ha una risposta spesificosa. Provo a salvare queste due KEY come una fila diversa alla mia tabella .:
12E60AED-7491-49B3-8006-78ECEA63B376 12e60aed-7491-49b3-8006-78ecea63b376
Questo è il mio attributo di classe:
[AttributeUsage(AttributeTargets.Property, AllowMultiple = true)]
public class CaseSensitive : Attribute
{
public CaseSensitive()
{
IsEnabled = true;
}
public bool IsEnabled { get; set; }
}
Questo è il mio modello di db:
[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; }
}
Questo è entityContex:
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Conventions.Add
(new AttributeToColumnAnnotationConvention<CaseSensitive, bool>
("CaseSensitive", (property, attributes) => attributes.Single().IsEnabled));
}
Ma non funziona, quando guardo caseSensitive da tableDesigner-Collation CaseSensitive è disabilitato. Come posso lavorarlo?
Trovo risposta Scrivo CaseSensitive dopo [Key] e questo lavoro. Non so come ..:
[Key]
[CaseSensitive]
[Column( TypeName= "varchar" , Order =0), MaxLength(36) ]
public string StandardBusinessDocumentGuid { get; set; }