System.Data.SqlClient, Version=4.2.0.1 issues with Asp.Net Core


Today I received the following exception when publishing a site that was working locally for me:

Exception

    System.IO.FileLoadException: Could not load file or assembly 'System.Data.SqlClient, Version=4.2.0.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

After trial and erroring for an hour about whether some references I had to the .Net Standard version of System.Data.SqlClient might be causing the issue I decided to go to the remote site, completely delete all the files and re-publish in case there was an old assembly hanging out causing the issue. Sure enough, that fixed the issue. I suspect that during the process of updating NuGet packages that my deploy process left some old assemblies on my site that caused this conflict.