I have a property on aa page that does some database mapping (mapping a page to one or more user classes in this case). The property writes to the database when a page is published instead of storing it's data on the page.
It works fine when editing the property on an existing page, but when editing it on a page that is just being created, I only get the ID of 0.
So is there any way for a property to know the id of the page it's on in the applyEditChanges event while the page is being published for the first time?
No, there's not because the page only gets it's ID when it's saved. You probably have to move your logic to a handler for the DataFactory.PageSaved or PagePublished event. That means you have to store your data in the PageData at least temporarily. Or store a reference to the "unlinked" entry in your custom database and then link it to the page ID in your event handler. These are just some suggestions, there surely other ways to do this as well.