title: Handling migrations with MongoDb
body: <p>Just to give a little more context to the question, I have a web application (asp mvc) which basically wraps CRUD operations to a MongoDb instance, it carries out validation and certain business logic before the model is verified and sent over to be stored, retrieved etc.</p>
  
  <p>Now one problem we have his is that in the new version the models have changed but the existing data has not, here is an example: (it is c# specific but the question really is language agnostic)</p>
  
  <pre><code>public class Person
  {
      public Guid Id {get; set;}
      public string Name {get; set;}
      public int Age {get;set;}
      public string BadgeNo {get;set;}
  }
  
  public class Person
  {
      public Guid Id {get; set;}
      public string Name {get; set;}
      public int Age {get;set;}
      public string EmployeeNo {get; set;} // Still contains same data as BadgeNo just called something different
  }
  </code></pre>
  
  <p>As you can see the structure of the objects have changed but in Mongo land it is still passing out a BadgeNo, not an EmployeeNo. In an SQL land we would usually have a migration script which is run as part of the build script which would change the schema and update/insert/delete any additional data for that delta.</p>
  
  <p>So how is it best to manage these sort of <em>migrations</em> with Mongo? Should I also have a script which I use to update all instances within Mongo? or is there some other preferred practise for doing this sort of thing.</p>
  
  <p>Any advice on the subject would be great</p>
  
  <p>=== Edit ===</p>
  
  <p>It seems like currently I am wanting to go with the migration option rather than a phasing out approach, so with this in mind can anyone recommend any tools for helping in this area, as otherwise each migration (assuming a roll-in, roll-out) would have to be a pre compiled assembly of some kind with all the logic in. I was thinking something along the lines of FluentMigrator but instead of working with SQL you are working with Mongo. Currently my build scripts are using Nant, I have seen some ruby tools but not sure if there are any .net equivalent.</p>