title: API Versioning - What do I do if model changes
body: <p>I'm fairly new with APIs and versioning but from what I understand, the developer (which is me) should retain the code if there will be a contract breaking change for the API. Correct me if I'm wrong but I consider Model changes as contract breaking change.</p>
  
  <p>So my question is - Do you make a new model (ex. ModelName.V2) just for the sake of versioning? Is there a better way to do this? This would mean even a slight change in property in my model would mean I would iterate it to another version.</p>
  
  <p>p.s. let me know if I need to edit my question as I'm also fairly new in StackOverflow.</p>
  
  <p>Sample</p>
  
  <pre><code>public class Product
  {
      public int ID {get;set;}
      public string Name {get;set;}
  }
  </code></pre>
  
  <p>and accompanying Controller</p>
  
  <pre><code>[ApiVersion("1.0")]
  [Route("api/v{version:apiVersion}/[controller]/[action]")]
  public class Products : Controller
  {
     Product[] prod = new Product[]{
         new Product(){ID = 1, Name = "T-Shirt"},
         new Product(){ID = 2, Name = "Jeans"}
     };
  
  
     [HttpGet]
     [ActionName("gotcha")]
     public IActionResult GetProduct()
     {
         return Ok(prod);  
     }
  }
  </code></pre>
  
  <p>and for V2 Controller</p>
  
  <pre><code>[ApiVersion("2.0")]
  [Route("api/v{version:apiVersion}/[controller]/[action]")]
  public class V2.Products : Controller
  {
         [HttpGet]
         [ActionName("gotcha")]
         public IActionResult GetProduct()
         {
             var trash = "Hello World!";
             return OK(trash);  
         }
  }
  </code></pre>
  
  <p>The above codes are what I understand as contract breaking and needed versioning and below is my problem with Model contract breakage:</p>
  
  <pre><code>public class Product
  {
     public int ID {get;set;}
     public string Name {get;set;}
     public decimal Price {get;set;}
  }
  </code></pre>
  
  <p>So the sample above shows I added a new property. This I consider as contract breakage and do I iterate a new controller version and then retain the old Model as well? In the future this will be messy if I keep legacy versions.</p>