C
C#9mo ago
IchiroKyou

✅ Two calls to same microservice inside one transaction

Greetings, I have a .NET Core Web client that is accessing a .NET Core API microservice (that uses Entity Framework and Identity). In this service I have a method that creates a user, and another that adds a role to a user. I want to make sure that: 1) the role is added to the user, only if the user is created; 2) the user is only created if the role can also be added, after creation. Basically I only want to commit to the database if both the user is created and the role is added to said user. I could achieve this by using a transaction scope in the microservice, but for this specific project I want to keep those two methods separate, and I want to create this transaction at the level of the client, like this: Register (Client): Create Transaction (Client): CreateUser (Service) AddRole (Service) Commit/Rollback (Client) a) Would this be considered a distributed transaction (even if it's for the same database)? b) Can something like this be achieved using only EF as is? c) Do I need to implement a sort of unit of work pattern in the microservice to acheve this? Thank you for your help
1 Reply
Unknown User
Unknown User9mo ago
Message Not Public
Sign In & Join Server To View