One of the common design patterns in enterprise software development which allows one to maintain a list of objects affected by a business transaction and coordinates the writing out of changes and the resolution of concurrency problems.
Questions tagged [unit-of-work]
1052 questions
144
votes
3 answers
Generic Repository With EF 4.1 what is the point
As i dig deeper in to the DbContext, DbSet and associated interfaces, I am wondering why you would need to implement a separate "Generic" Repository around these implementations?
It looks like DbContext and IDbSet do everything you need and include…

Code Jammr
- 1,867
- 3
- 14
- 18
76
votes
7 answers
How to implement Unit Of Work pattern with Dapper?
Currently, I am trying to use Dapper ORM with Unit Of Work + Repository Pattern.
I want to use Unit of Work as opposed to a simple dapper Repository due to the fact that my insert and updates require a degree of transaction processing. I have been…

Stig
- 1,169
- 1
- 9
- 12
63
votes
8 answers
Unit of Work + Repository Pattern: The Fall of the Business Transaction Concept
Combining Unit of Work and Repository Pattern is something used fairly widely nowadays. As Martin Fowler says a purpose of using UoW is to form a Business Transaction while being ignorant of how repositories actually work (being persistent…

Alireza
- 10,237
- 6
- 43
- 59
51
votes
7 answers
Entity Framework 6 Code First - Is Repository Implementation a Good One?
I am about to implement an Entity Framework 6 design with a repository and unit of work.
There are so many articles around and I'm not sure what the best advice is: For example I realy like the pattern implemented here: for the reasons suggested in…

davy
- 4,474
- 10
- 48
- 71
51
votes
3 answers
Dependency injection in unit of work pattern using repositories
I want to create a unit of work class that wraps around repositories in a similar way to this.
The problem I'm having is trying to implement dependency injection by replacing the generic repositories in the example with an IRepository interface. In…

rashleighp
- 1,226
- 1
- 13
- 21
45
votes
2 answers
Benefit of using Unit of Work and Repository Patterns with Entity Framework
According to MSDN, DbContext is defined as:
Represents a combination of the Unit-Of-Work and Repository patterns
and enables you to query a database and group together changes that
will then be written back to the store as a unit.
Since…

Usman Khalid
- 3,032
- 9
- 41
- 66
45
votes
3 answers
Singleton Per Call Context (Web Request) in Unity
A few days ago, I had an issue with ASP.Net threading. I wanted to have a singleton object per web request. I actually need this for my unit of work. I wanted to instantiate a unit of work per web request so that identity map is valid through out…

Mehdi Khalili
- 927
- 1
- 11
- 18
41
votes
5 answers
Repository and Unit of Work patterns - How to save changes
I'm struggling to understand the relationship between the Repository and Unit of Work patterns despite this kind of question being asked so many times. Essentially I still don't understand which part would save/commit data changes - the repository…

Peter Monks
- 4,219
- 2
- 22
- 38
35
votes
3 answers
Tracking model changes in SQLAlchemy
I want to log every action what will be done with some SQLAlchemy-Models.
So, I have a after_insert, after_delete and before_update hooks, where I will save previous and current representation of model,
def keep_logs(cls):
…

V. Gamula
- 4,971
- 3
- 15
- 18
35
votes
1 answer
Register partically closed generic type with Autofac
I have UnitofWork class and it implement IUnitOfWork. I try to register that with Autofac:
var builder = new ContainerBuilder();
builder
.RegisterGeneric(typeof(UnitOfWork,>))
.As(typeof(IUnitOfWork))
…

shortcode
- 417
- 1
- 4
- 10
34
votes
4 answers
ASP.NET Identity with Repository and Unit of Work
I'm learning Repository and Unit of Work patterns in ASP.NET MVC 5 application with Entity Framework 6.
I had already read a lot of tutorials and articles, but almost all of them are condradictory. Ones say that Repository and Unit of Work patterns…

Aleksanderis
- 597
- 1
- 5
- 18
33
votes
1 answer
Entity Framework 6 and Unit Of Work... Where, When? Is it like transactions in ado.net?
Creating a new MVC project and like the idea of repositories in the data layer, so i have implemented them. I have also created a Service layer to handle all business logic and validation, this layer in turn uses the appropriate repository. …

Gillardo
- 9,518
- 18
- 73
- 141
29
votes
4 answers
Is Unit Of Work and Repository Patterns very useful for big projects?
I'm starting a new web project using ASP.NET Webforms + EF4. I'm trying to apply a repository pattern with a unit of work pattern following this tutorial :…

mehmetserif
- 1,185
- 7
- 26
- 48
26
votes
3 answers
Avoid Unit of Work pattern in domain driven design
I have read this and it makes me think twice...:
"Avoid unit of work pattern. Aggregate roots should define transaction boundaries."
Why should someone avoid the UOW pattern applying domain driven design?

Elisabeth
- 20,496
- 52
- 200
- 321
24
votes
2 answers
Is UnitOfWork equals Transaction? Or it is more than that?
The internet is full of information about UnitOfWork pattern; even SO is not an exception.
I still do not understand something about it. In my understanding UnitOfWork = Transaction in DB. Thats all; nothing more, nothing less.
Is this correct?
My…

Amit Joshi
- 15,448
- 21
- 77
- 141