You need to reload the entity after saving changes. Because it has been altered by a database trigger which cannot be tracked by EF. SO we need to reload the entity again from the DB,
db.Entry(MyNewObject).GetDatabaseValues();
Then
int id = myNewObject.Id;
Look at @jayantha answer in below question:
How can I get Id of the inserted entity in Entity framework when using defaultValue?
Looking @christian answer in below question may help too: