When I try to map a column to a char data type in my model class I get an error:
The property \'[ColumnName]\' is not a declared property on type \'
This is interesting but you really cannot map char
property. I just checked it and if you want to have char(1)
in the database you must use string
property with following mapping:
modelBuilder.Entity<MyEntity>()
.Property(p => p.MyProperty)
.HasMaxLength(1)
.IsFixedLength()
.IsUnicode(false);
It is not only problem of Code-first. It is whole EF limitation because EDMX designer also doesn't show char
type. I think allowed types will be same as described in CSDL reference for EDMX because code first is just wrapper around the same mapping infrastructure.