{"id":743,"date":"2020-06-13T10:34:50","date_gmt":"2020-06-13T10:34:50","guid":{"rendered":"https:\/\/bruceng.com\/dev\/?p=743"},"modified":"2020-06-13T10:34:50","modified_gmt":"2020-06-13T10:34:50","slug":"unit-testing-code-using-entity-framework-core","status":"publish","type":"post","link":"https:\/\/bruceng.com\/dev\/?p=743","title":{"rendered":"Unit testing code using Entity Framework Core"},"content":{"rendered":"\n<p><a href=\"https:\/\/docs.microsoft.com\/en-us\/ef\/core\/miscellaneous\/testing\/\">https:\/\/docs.microsoft.com\/en-us\/ef\/core\/miscellaneous\/testing\/<\/a><\/p>\n\n\n\n<p>I tried to use Moq to mock the DbContext and IQueryable&lt;>, but it seems to be really complicated. It&#8217;s also not recommended by Microsoft.<\/p>\n\n\n\n<p>For unit testing, it&#8217;s recommended to use a real database, perhaps using an in-memory database or a temporary sqlite database. Whatever the type of database you use, install the required NuGet package.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>https:\/\/docs.microsoft.com\/en-us\/ef\/core\/miscellaneous\/testing\/ I tried to use Moq to mock the DbContext and IQueryable&lt;>, but it seems to be really complicated. It&#8217;s also not recommended by Microsoft. For unit testing, it&#8217;s recommended to use a real database, perhaps using an in-memory database or a temporary sqlite database. Whatever the type of database you use, install the required &hellip; <a href=\"https:\/\/bruceng.com\/dev\/?p=743\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Unit testing code using Entity Framework Core&#8221;<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14],"tags":[105,37],"class_list":["post-743","post","type-post","status-publish","format-standard","hentry","category-tips-and-tricks","tag-entity-framework-core","tag-unit-testing"],"_links":{"self":[{"href":"https:\/\/bruceng.com\/dev\/index.php?rest_route=\/wp\/v2\/posts\/743","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bruceng.com\/dev\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bruceng.com\/dev\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bruceng.com\/dev\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/bruceng.com\/dev\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=743"}],"version-history":[{"count":1,"href":"https:\/\/bruceng.com\/dev\/index.php?rest_route=\/wp\/v2\/posts\/743\/revisions"}],"predecessor-version":[{"id":744,"href":"https:\/\/bruceng.com\/dev\/index.php?rest_route=\/wp\/v2\/posts\/743\/revisions\/744"}],"wp:attachment":[{"href":"https:\/\/bruceng.com\/dev\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=743"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bruceng.com\/dev\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=743"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bruceng.com\/dev\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=743"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}