Say a SQL table contains a column of char(10)
, and a record contains the value “ABC” in that column. Entity Framework will pass ABC
(“ABC” with 7 trailing spaces) when asked for the value.
Is there a way to ask Entity Framework to ignore trailing whitespace when getting the value of a column of type char
, essentially having EF treat it like a varchar
instead?
A quick look at the methods available in the fluent API has yielded no obvious solutions.Removing entity.Property(e => e.CharColumn).IsFixedLength()
does not produce the desired effect of trimming trailing whitespace.
Changing the type of the column from char
to varchar
in the SQL database is not an option in my use case as it could interfere with other programs beyond my control which read this table.