Mocking Your File System

Introduction In this post, I’m going to talk about basic dependency injection and mocking a method that is used to access hardware.  The method I’ll be mocking is the System.IO.Directory.Exists(). Mocking Methods One of the biggest headaches with unit testing is that you have to make sure you mock any objects that your method under … Read moreMocking Your File System

Stored Procedures Vs. No Stored Procedures

There is this debate raging among developers: “Is it better to use stored procedures or not use stored procedures”.  From first glance, this seems like a simple question, but there are some complicated implications around this question.  Here’s the basic pros and cons of using stored procedures in your system: Pros You can isolate table … Read moreStored Procedures Vs. No Stored Procedures

.Net MVC Project with AutoFac, SQL and Redis Cache

Summary In this blog post I’m going to demonstrate a simple .Net MVC project that uses MS SQL server to access data.  Then I’m going to show how to use Redis caching to cache your results to reduce the amount of traffic hitting your database.  Finally, I’m going to show how to use the AutoFac … Read more.Net MVC Project with AutoFac, SQL and Redis Cache

DotNet Core vs. NHibernate vs. Dapper Smackdown!

The Contenders Dapper Dapper is a hybrid ORM.  This is a great ORM for those who have a lot of ADO legacy code to convert.  Dapper uses SQL queries and parameters can be used just like ADO, but the parameters to a query can be simplified into POCOs.  Select queries in Dapper can also be … Read moreDotNet Core vs. NHibernate vs. Dapper Smackdown!

DBContextOptionsBuilder does not contain a definition for ‘UseSqlServer’

Attempting to use the correct NuGet packages for your code in .Net Core can be challenging.  In this instance there is no project.json error and yet this one property is missing: This will happen when your EF database project contains at least these two NuGet packages:     “dependencies”: {         “Microsoft.EntityFrameworkCore”: “1.1.1”,         “NETStandard.Library”: “1.6.1” … Read moreDBContextOptionsBuilder does not contain a definition for ‘UseSqlServer’