Start here. This is the direct spoken answer to practice first.
Why this question matters
This is a realistic backend design problem: the database update succeeds but the message publish fails, or the reverse. EF Core is usually sitting right at that boundary.
I would avoid publishing the message directly as a separate side effect after SaveChanges and pretending it is atomic. Instead, I would save the business change and an outbox record in the same database transaction. After the transaction commits, a background worker reads unsent outbox records and publishes them to the broker. That way the database contains a durable record of work that still needs to be sent.