Daily Learning – Fix your database project needing a reference to .NET Framework

Recently we were doing some work on ASP.NET Core Identity.  We created a SQL Server database project to contain the database and imported the existing database.  Unfortunately, we kept getting the following error on build.

Your project does not reference “.NETFramework,Version=v4.7.1” framework. Add a reference to “.NETFramework,Version=v4.7.1” in the “TargetFrameworks” property of your project file and then re-run NuGet restore

This seems quite odd because we don’t reference .NET Framework.  That aside the error was directly related to the target framework setting for SQLCLR.  Interestingly we are not using SQLCLR.  To cut to the answer, the issue was a file project.assets.json file in the obj directory.  I deleted the obj directory and rebuilt and now all is well.

Thanks to Max Jones who also had this problem and found the solution.