.net - Differences between create our own UoW/Repository vs using DbContext directly -


the description dbcontext says :"a dbcontext instance represents combination of unit of work , repository patterns...". many developers tend create own repositories , uow.

should use dbcontext , dbset directly or should there own repositories ? differences.

is there problem if use dbcontext directly ? how if switch ms sql oracle in future ?

follow msdn

other times, may want write own application-specific unit of work interface or class wraps inner unit of work persistence tool. may number of reasons. might want add application-specific logging, tracing, or error handling transaction management. perhaps want encapsulate specifics of persistence tooling rest of application. might want encapsulation make easier swap out persistence technologies later. or might want promote testability in system. many of built-in unit of work implementations common persistence tools difficult deal in automated unit testing scenarios.

come questions.

should use dbcontext , dbset directly or should there own repositories ?

in fact, there no problem when put dbcontext , dbset repositories. ask ourselves test more easier ot not. if want design framework testing should not use dbcontext , dbset directly repositories. should use interface idbcontextfactory use provide dbcontext, 2 cents.

to have many views repository can take reference link below consider options between repository , dbcontext.

http://huyrua.wordpress.com/2010/07/13/entity-framework-4-poco-repository-and-specification-pattern/

is there problem if use dbcontext directly ?

no, there no problem if use dbcontext directly. messy many business rules , tons of scale issues centralize database, difficult test , violate separate of concern in design principle.

how if switch ms sql oracle in future ?

actually, there no problem when switch between ms sql , oracle in future. change data provider follow link below when use dbcontext of entity framework.

http://www.devart.com/news/2008/directs475.html

or ms entity framework oracle provider


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -