mardi 14 avril 2015

Entity Framework 6: async, sync and transactions


Vote count:

1




I'm using ASP.NET MVC and EF 6 and I have a controller that calls my service layer to perform some actions. One of those actions must be async so the controller can return a view before that action is complete. This is how it looks:



  1. Controller action being executed.

  2. Invoke Service.

  3. Service performs some actions that save data in the DB.

  4. Services starts a new task (Task.Factory.StartNew(() => X()) and return control to the Controller.

  5. Controller calls another service that tracks user actions. This is where it fails because the async operation I started on (4) uses a transaction and they are sharing the same DbContext.


How should I handle this?



asked 1 min ago







Entity Framework 6: async, sync and transactions

Aucun commentaire:

Enregistrer un commentaire