Posts

Showing posts from December 27, 2018

Why is EF treating a char property as an actual guid?

Image
0 What I have actually is a property of type char which I use to store the string value of a guid. My current setup: - MySQL - EF Code-First - EF Migration Model: public class Employee { public string Id { get; set; } } EF config public class EmployeeConfiguration : EntityConfiguration<Employee> { public EmployeeConfiguration() { HasKey(x => x.Id); Property(x => x.Id) .HasColumnType(“char”) .HasMaxLength(36) .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None); } } The problem: System.FormatException is thrown if I do the following: 1. Insert with an Id that doesn’t follow the format of a guid. 2. Querying the above Employee class from database that contains an Id that doesn’t follow the for...