title: How does EF Code-First migration tool figure out which changes were made to the model?
body: <p>I'm learning migrations and I'm curious how migration tool figures out which changes to our model were made after the last migration was created. </p>
  
  <p>For example, assume we created a migration <strong>M1</strong> and apply it by issuing command <code>Update-Database</code>. After applying <code>M1</code>, if we add a new property <code>P</code> to a class <code>C</code> and create another migration <strong>M2</strong> by issuing command <code>Add-Migration M2</code>, then migration tool will somehow be able to figure out that only change ( after <strong>M1</strong> was created ) we made to the model was adding a new property <code>P</code> to class <code>C</code>. How does migration tool figure that out?</p>
  
  <p>thank you</p>
  
  <p><strong>REPLY:</strong></p>
  
  <p>Migrations uses <strong>__Migrations</strong> table to figure which migrations have already been applied and which have yet to be applied, but I thought it doesn't use this table to also figure out what changed from one migration to another, since data in migrations table is a <strong>hash</strong>, which means it can't be decrypted, which I assume would be necessary so that current model metadata can be compared with latest metadata stored in the migrations table?!</p>
  
  <p>Or are you implying that it is able to figure out just by comparing hash values ( of current and stored versions ) which properties have changed or were deleted or were added to an entity?</p>