c# - How to avoid declaring database fields twice, once in database, once in a repository/model? -
i began reading pro asp.net mvc framework.
the author talks creating repositories, , using interfaces set quick automated tests, sounds awesome.
but carries problem of having declare fields each table in database twice: once in actual database, , once in c# code, instead of auto-generating c# data access classes orm.
i understand great practice, , enables tdd looks awesome. question is:
isn't there workaround having declare fields twice: both in database , c# code? can't use auto-generates c# code still allows me tdd without having manually create business logic in c# , creating repository (and fake 1 too) each table?
if use entity framework 4, can generate poco object automatically database. ( http://blogs.msdn.com/b/adonet/archive/2010/01/25/walkthrough-poco-template-for-the-entity-framework.aspx)
then can implement generic irepository , generic sqlrepository, allow have repository objects. explained here : http://msdn.microsoft.com/en-us/ff714955.aspx
this clean way achieve want: declare object once in database, generate them automatically, , can access them repository (in addition can ioc , unit test :) )
i recommend read second edition of book pure gold , updated new features introduced in mvc 2 http://www.amazon.com/asp-net-framework-second-experts-voice/dp/1430228865/ref=sr_1_1?s=books&ie=utf8&qid=1289851862&sr=1-1
and should read new features introduced in mvc3 in rc (there new view engine useful) http://weblogs.asp.net/scottgu/archive/2010/11/09/announcing-the-asp-net-mvc-3-release-candidate.aspx
Comments
Post a Comment