.NET Core - MVC

Observations about .NET Core, MVC and converting YetaWF from ASP.NET MVC5 to .NET Core MVC. The new .NET Core has great new features. Getting there from an existing MVC 5 app is HARD!

Don't Let System.Data.SqlClient Happen To You!


I spent about a week chasing a "mysterious" hang in my application. While it was somewhat easy to recreate, I had no clue why it was hanging. Always on ExecuteReaderAsync.

This is an ASP.NET Core 3.1 application. The code that ended up hanging is quite old and used in many other sites, so I was stumped. I started refactoring, cleaning up some async/await stuff that looked suspicious, even though it had been in use for a few years and still is in some other sites. Everytime I made a significant change, the problem would move elsewhere, always somewhere in an ExecuteReaderAsync (or similar SQL, SqlClient) call.

I was ready to give up and declare, we don't need this new product. It doesn't work. It seemed like the small bit of code I added for this new project simply did not work within the YetaWF framework. But very similar code in the same application worked just fine.

After a week of cursing, refactoring, kicking over the furniture, heavy drinking, I finally found the problem. Well, not really. I decided that System.Data.SqlClient simply doesn't work correctly on Linux (Docker) with ASP.NET Core 3.1. How did I come to that conclusion you ask? I used Microsoft.Data.SqlClient instead. And the exact same code now works just fine.

I won't start complaining now that System.Data.SqlClient doesn't work or that Microsoft decided to create a new package (Microsoft.Data.SqlClient) where enhancements to SqlClient are made, because everyone knows that's what happened. We all read all the blogs the fan bois write about the most important package in their lives. So with the ~300 packages used by my apps, I of course always stay current with news about the packages. And also any new packages that replace the packages I use. Oh, sorry, that's wrong, I don't. I have work to do.

I'm not going to complain about System.Data.SqlClient not being updated, but instead a new package is created (Microsoft.Data.SqlClient). Why not? Because apparently that is the way things are done now and I don't want anyone to say "OK, Boomer" (yeah, I got into that club by a hair).

No Comments

Be the first to add a comment!

Add New Comment

Complete this simple form to add a comment to this blog entry.