Using Both (Extend & Override)
You’re not limited to just one approach—you can combine overriding existing methods and adding new ones in a single custom Unit of Work class.
This gives you maximum flexibility:
Override methods to change or enhance built-in data/transaction behavior.
Extend by introducing brand new methods tailored to your project’s needs.
For example, you might override SaveChangesAsync to add auditing, while also introducing a new utility method like ClearAllTables.
This is the true power of REN.Kit’s design: your Unit of Work can be as standard or as custom as you need.
Pro Tip:
Just inherit from the base unit of work (like RENUnitOfWork<TDbContext>), override any built-in methods you want, and add your own new methods—all in the same class!
How to Use Both? (Override + Extend)
1. Create a New Interface for Your Custom Methods
public interface IExtendedRENUnitOfWork<TDbContext> : IRENUnitOfWork<TDbContext>
where TDbContext : DbContext
{
void AdditionalMethod();
}This interface introduces your new method(s) while keeping all defaults.
2. Implement Your Custom Unit of Work
3. Register Your Custom Implementation
Since you’re introducing a new interface and class, register both:
The registration method (for reference):
4. Use Your Custom Unit of Work in Action
Pro Tip:
You can mix and match: override built-in transaction or repository logic, and add brand new helpers or project-specific utilities—all in one place.
And you're good to go!
With this approach, your Unit of Work becomes a tailored orchestration layer perfectly suited to your app’s evolving requirements.
Last updated