﻿var docUrl = new NSUrl (path);
var doc = new UIManagedDocument (docUrl) {
    PersistentStoreOptions = NSDictionary.FromObjectsAndKeys (
	new object [] { true, true },
	new object [] { NSPersistentStoreCoordinator.MigratePersistentStoresAutomaticallyOption,
			NSPersistentStoreCoordinator.InferMappingModelAutomaticallyOption })
};

if (NSFileManager.DefaultManager.FileExists (path)){
    doc.Open ((success)=> {
        if (!success){
	    // Handle error
	}
     });
} else {
	AddInitialData ();
	doc.Save (docUrl, UIDocumentSaveOperation.ForCreating, (success) => {
	    if (!success){
	        // handle error
	    }
	});
}
