{"id":18,"date":"2018-07-31T11:55:00","date_gmt":"2018-07-31T16:55:00","guid":{"rendered":""},"modified":"2023-07-26T12:51:48","modified_gmt":"2023-07-26T17:51:48","slug":"post-mortem-using-the-repository-pattern-with-entity-framework","status":"publish","type":"post","link":"https:\/\/www.chrystalsander.com\/blog\/?p=18","title":{"rendered":"Post-Mortem:  Using the Repository Pattern With Entity Framework"},"content":{"rendered":"<p><span style=\"font-family: inherit;\">Dear all future developers who may get stuck dealing with a couple of applications I&#8217;ve written over the past year or so.&nbsp; I know that much future cursing at me is on the way.&nbsp; Much to my regret, I confess I used repositories with Entity Framework<i> Code-Firs<\/i>t.<\/span><br \/>\n<span style=\"font-family: inherit;\"><br \/><\/span><br \/>\n<span style=\"font-family: inherit;\">&#8230;and I didn&#8217;t just use one or two,&nbsp; I added at least four or five &#8212; <i>on top of a<\/i> BASE repository.&nbsp; To make it worse, I even created a BaseController to deal with all this so that now I have inheriting controllers that have to deal with ramifications.&nbsp;<\/span><br \/>\n<span style=\"font-family: inherit;\"><br \/><\/span><br \/>\n<span style=\"font-family: inherit;\">The severity of the above could have been significantly reduced if I had written proper unit tests.&nbsp; In one app, I actually DID write (improper &#8212; with very little mocking) unit tests first but because the tests now need to run on an independent build server, I have to suffer to re-write them quickly to meet a deadline but, the reality is, the apps need re-architecture.&nbsp; &nbsp; <\/span><br \/>\n<span style=\"font-family: inherit;\"><br \/><\/span><br \/>\n<span style=\"font-family: inherit;\">I&#8217;m working on a prototype with better architecture&nbsp; but that will probably not have time to go through the the whole integration testings, etc.&nbsp; <\/span><br \/>\n<span style=\"font-family: inherit;\"><br \/><\/span><br \/>\n<span style=\"font-family: inherit;\">Thanks&nbsp;<span data-darkreader-inline-bgcolor=\"\" data-darkreader-inline-bgimage=\"\" data-darkreader-inline-color=\"\" dir=\"ltr\" style=\"background: rgb(37 , 45 , 49); color: #acb2b6; direction: ltr; font-size: 14px; font-weight: 700; unicode-bidi: embed;\"><a data-darkreader-inline-bgcolor=\"\" data-darkreader-inline-bgimage=\"\" data-darkreader-inline-color=\"\" href=\"https:\/\/twitter.com\/hoagieland\" style=\"--darkreader-inline-bgcolor: #2f3139; --darkreader-inline-bgimage: initial; --darkreader-inline-color: #c2b29c; background: rgb(37, 45, 49); color: #acb2b6; font-size: 14px; font-weight: 700;\">@<span style=\"font-weight: normal;\">hoagieland<\/span><\/a>&nbsp;for your <a href=\"https:\/\/medium.com\/@hoagsie\/youre-all-doing-entity-framework-wrong-ea0c40e20502\" target=\"_blank\" rel=\"noopener\">post<\/a>.&nbsp; It might be a little extreme but with many valid points.<\/span><\/span><br \/>\n<span style=\"font-family: inherit;\"><span data-darkreader-inline-bgcolor=\"\" data-darkreader-inline-bgimage=\"\" data-darkreader-inline-color=\"\" dir=\"ltr\" style=\"background: rgb(37 , 45 , 49); color: #acb2b6; direction: ltr; font-size: 14px; font-weight: 700; unicode-bidi: embed;\"><br \/><\/span><br \/>\nAll who have to deal with this particular flavor should read:<\/span><\/p>\n<p><center><br \/>\n<a href=\"https:\/\/medium.com\/@hoagsie\/youre-all-doing-entity-framework-wrong-ea0c40e20502\" target=\"_blank\" rel=\"noopener\"><span style=\"font-size: large;\">You\u2019re All Doing Entity Framework Wrong<\/span><\/a> <\/center><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Dear all future developers who may get stuck dealing with a couple of applications I&#8217;ve written over the past year or so.&nbsp; I know that much future cursing at me is on the way.&nbsp; Much to my regret, I confess I used repositories with Entity Framework Code-First. &#8230;and I didn&#8217;t just use one or two,&nbsp; &hellip; <a href=\"https:\/\/www.chrystalsander.com\/blog\/?p=18\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Post-Mortem:  Using the Repository Pattern With Entity Framework&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,8],"tags":[39,73],"_links":{"self":[{"href":"https:\/\/www.chrystalsander.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/18"}],"collection":[{"href":"https:\/\/www.chrystalsander.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.chrystalsander.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.chrystalsander.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.chrystalsander.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=18"}],"version-history":[{"count":1,"href":"https:\/\/www.chrystalsander.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/18\/revisions"}],"predecessor-version":[{"id":151,"href":"https:\/\/www.chrystalsander.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/18\/revisions\/151"}],"wp:attachment":[{"href":"https:\/\/www.chrystalsander.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=18"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.chrystalsander.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=18"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.chrystalsander.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=18"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}