The code’s expecting ‘Bundle.main.url()’ to return a value (with the ! meaning the app should crash if the function unexpectedly returns nil). I would double check: what’s the value of ‘modelName’ and does the project have a resource with that name of type ‘.momd’?
I would agree that logic suggests that, I do have a question though, why did it work with Swift 2, but not with Swift 3? The type “momd” is boiler plate provided by Apple, so the Core Data app should be expecting it and not all data bases come pre-loaded.