title: Why does Entity Framework not return a trimmed string for a nvarchar(MAX) field?
body: <p>I'm currently working on a Silverlight application connected to a SQL Server 2008 Express database that is largely based on <a href="http://blogs.msdn.com/brada/archive/2009/07/11/business-apps-example-for-silverlight-3-rtm-and-net-ria-services-july-update-part-1-rich-data-query.aspx" rel="nofollow noreferrer">a demo on Brad Abrams' blog</a>.  <em>(NOTE: The demo file at the specified link is actually a different solution that the one he shows on the <a href="http://www.hanselman.com/abrams/#/Home" rel="nofollow noreferrer">live running application</a>.  The demo in the blog post uses Entity Framework, while the live application uses POCO).</em></p>
  
  <p>I am trying to figure out why Entity framework is returning a fixed width string for fields that are set up as nvarchar(MAX).  (By "Fixed Width," I mean something like "DC        ", where there's white space at the end of the content of the string).  </p>
  
  <p>In the demo file, which is connected to an included MDF file, the Name field is a nvarchar(max) field, and entity framework correctly returns the trimmed string.  However, in my personal application, which is connected to a SQLEXPRESS database, a nvarchar(max) field is still returned with the white space at the end, fixed width, and untrimmed.  When I hover over the <code>return this._itemPrefix;</code> line of Entity Model C# file at runtime, it shows the item with the white space, untrimmed.  I can't figure out why it works in his demo but not in my file.</p>
  
  <p>Is there something I can do other than alter the code in the entityModel.Designer.cs to have it return a trimmed string?  Has anyone else ran into this issue?</p>