title: How can I configure Entity Framework to automatically trim values retrieved for specific columns mapped to char(N) fields?
body: <p>I'm working with a third-party database in which all text values are stored as <code>char(n)</code>. Some of these text values are primary keys, whereas others are just normal human-readable text. For the latter, I want retrieved values to be automatically trimmed.</p>
  
  <p>I know I can add <code>Trim</code> to all of my LINQ to Entities queries, but this is messy, unreliable and unmaintainable. I would like to somehow configure Entity Framework to automatically trim values retrieved from specific columns.</p>
  
  <p>However, I don't know how to do this. I'm using EF's fluent API. The closest thing I've thought of so far is creating additional properties to wrap the real properties with <code>Trim</code> method calls, but this is messy and still not very maintainable. I would also prefer for the trimming to occur in the database rather than the application.</p>