title: How can I manage changing data structures in MongoDb collections w/ Simple.Data?
body: <p>We're currently using Simple.Data and the MongoDb adapter.  When we've retrieved a document, we cast it into a POCO, e.g:</p>
  
  <pre><code>(User)db.Users.FindById(1234);
  </code></pre>
  
  <p>To begin with, this works quite well (heck yeah, no schema!).  However, if we change the structure of the User object (e.g. add a new field, or change a field's data type), then we can no longer cast the original document, as it doesn't match our new class structure.</p>
  
  <p>To resolve this, we've so far tried the two most straight-forward approaches:</p>
  
  <ol>
  <li>Manual data updates to reflect changes in document structure.  Ok at the moment, but not manageable when the project is deployed across multiple environments / makes it into production</li>
  <li>Manual mapping; eg. casting the SimpleRecord to a dictionary and evaluating members manually.  I'm concerned about performance of this approach, though haven't bench-marked it yet.  I'm also concerned that I haven't found a way to make it generic without using reflection on the destination type to identify member names.</li>
  </ol>
  
  <p>We've also looked into ways this was solved with <a href="https://github.com/terrbear/mongrations" rel="nofollow">Ruby</a> and <a href="http://merciless.sourceforge.net/tour.html" rel="nofollow">Python</a>.  The former appeals more (the maintenance of old schema versions in Ming seems like it may be overkill).</p>
  
  <p>Before I run off and port something crazy, has anyone solved this problem with Simple.Data?  Can anyone offer any guidance as to best practices for dealing with document structure changes in schema-less databases?</p>