Simplify common data access functions by using Entity Framework extens

added by goranobradovic
9/30/2011 9:12:34 AM

2 Kicks, 225 Views

Simple project featuring usage of EntityFramework CodeFirst and overriding SaveChanges method of DBContext in order to keep record of changes on entities in database. There is a simple usage sample project and a test project with couple of test cases to confirm that everything is working.


9/30/2011 9:13:16 AM
You've nailed it here, the repository pattern is not what we want. Entity Framework already implements the unit-of-work pattern via the context object, as you point out. Extending it there is the correct choice, rather than trying to mix and match the unit-of-work and repository patterns.

10/1/2011 4:28:51 AM
I am bit confused by IEntityMap and JContext. Are these classes some kind of custom classes? Or is it part of a framework?

10/1/2011 4:42:35 AM
These are custom classes, but JContext inherits from DbContext, which is part of EntityFramework (4.1). You have full source code on github (link in article), and you can download it to see/use it.

10/1/2011 6:09:24 AM
Thanks. I will check the link.