Skip to main content

290 posts tagged with ".NET"

.NET Framework and Core for Application Development

View All Tags

Fixed: "Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool" with MySql.Data

· 7 min read
Jagdish Kumawat
Founder @ Dewiride

A request that normally takes a millisecond failed after exactly 15 seconds with error connecting: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. MySQL itself was fine and nearly idle. All the app's connections were taken, by requests that were never going to finish.

Fixed: A Request Never Answers When a MySQL Statement Runs Longer Than CommandTimeout (MySql.Data)

· 8 min read
Jagdish Kumawat
Founder @ Dewiride

I set a short CommandTimeout, expecting an error when a statement ran too long. Instead, the request never answered at all. MySQL had finished long ago, and the connection sat idle, out of reach of everything else. If you're on Oracle's MySql.Data, any async statement slower than CommandTimeout can do this, including a default of 30 seconds behind a row lock.

Fixed: EF Core EnableRetryOnFailure Doesn't Retry MySQL Errors with Oracle's MySql.EntityFrameworkCore

· 7 min read
Jagdish Kumawat
Founder @ Dewiride

I had EnableRetryOnFailure turned on, so I assumed a deadlock or a short outage would be retried. With Oracle's MySQL provider, nothing was retried, ever, and no message says so. The provider asks each error whether it's temporary, and MySqlException always answers no. The fix is one argument.

How to Connect a .NET C# Web API to a MySQL Database — Part 3: Read and Write MySQL Data with EF Core

· 71 min read
Jagdish Kumawat
Founder @ Dewiride

Part 2 created the tables, and they're still empty. In this part the API starts using them: you'll insert, read, change and delete rows through real endpoints, and read the SQL that EF Core sends to MySQL for every one of them. You'll also turn MySQL's refusals, such as a duplicate name, into clear HTTP answers, and stop two people from silently overwriting each other's changes.

What UseAffectedRows Does in a MySQL Connection String for .NET C#

· 7 min read
Jagdish Kumawat
Founder @ Dewiride

When an UPDATE sets a column to the value it already has, did it affect the row? MySQL can answer either way, and a connection string option decides which you get. With Oracle's connector, the default is "yes", and that matters more than it looks. Turn the option on, and EF Core starts throwing an exception on some ordinary saves.

How to Set Different Log Levels per Environment in appsettings.json

· 5 min read
Jagdish Kumawat
Founder @ Dewiride

On your machine you want to see every SQL statement. In Production you don't: it's noise, and it costs money to store. ASP.NET Core reads appsettings.json, then the file for the current environment on top of it, so one setting in each gives you both. This guide does that for EF Core's SQL log, and checks it in both environments.