title: Core Data lightweight migration - do existing entities have new attributes added to them?
body: <p>I have a Core Data managed object model all set up and working in an iOS app, and I'm using NSManagedObject subclasses which are instantiated using <code>[[MyEntityClass alloc] initWithEntity:description insertIntoManagedObjectContext:context];</code></p>
  
  <p>I have been reading some tutorials on Core Data migrations to prepare for possible future updates to the app. For the changes I currently envisage for this particular case, I am confident that lightweight migration will be sufficient. I understand that lightweight migration maps the data from the old data model to the new version. But there is one thing I'm not clear in. If the persistent store contains NSManagedObject subclass instances which were created from before the migration, will these objects be modified along with the model to allow them to use the attributes added in the migration?</p>
  
  <p>I'll give an example to make sure I'm being clear about what I'm asking. Lets say I have an entity called, to use the classic example, <code>Person</code>. Person has the following attributes:</p>
  
  <pre><code>firstname
  lastname
  </code></pre>
  
  <p>I create an instance of <code>Person</code> called <code>aPerson</code> and this is inserted into the persistent store. I can access <code>aPerson</code>'s attributes using <code>aPerson.firstname</code> and <code>aPerson.lastname</code>.</p>
  
  <p>Now I add a <code>dateofbirth</code> attribute to the managed object model, so the <code>Person</code> entity contains the following attributes:</p>
  
  <pre><code>firstname
  lastname
  dateofbirth
  </code></pre>
  
  <p>Now, what happens if I retrieve <code>aPerson</code> from the persistent store and try to access <code>aPerson.dateofbirth</code>? Will I get an unrecognised selector error because <code>aPerson</code> does not contain the <code>dateofbirth</code> attribute due to being created before the addition of that attribute? Or will the lightweight migration add the <code>dateofbirth</code> attribute and the accessor methods to all instances of <code>Person</code> already in the persistent store?</p>