Abayomi Omosehin
1 min readSep 7, 2020

--

TRANSACTION WITH ENTITY FRAMEWORK 2

You can go through my last post on the theoretical part so as to be on the same plain of understanding.
https://medium.com/@omosehin14/transaction-in-entity-framework-4bf809be1fb9
Practically we will be using a School SURVEY for this implementation.

Student were to carry out a survey for the completion of a project. We have two basic tables: student table and the survey table. No use of Foreign key here. The student was asked to carry out a survey and the completion of the survey will be updated on the survey table.

So basically, we writes (saveChanges()) to the Database twice, a unit of work was started with begin transaction. It either get committed or rollback if either of the savings failed._dbContext is the connection to the database that uses constructor dependency injection. I hope this will help someone to solve bigger problem with this concept.

--

--