According to the articles I have read the correct way to enable core data light weight migrations is by passing options to addPersistentStoreWithType
:
With the new NSPersistentContainer
there are many sensible defaults. You don't have to set the properties, which most of the answers give.
Simply create the container and load.
let container = NSPersistentContainer(name: dataModelName)
container.loadPersistentStores { storeDescription, error in
// You may verify the default storeDescription has the right default for light migration
}