Skip to main content
Jagdish Kumawat
Founder @ Dewiride
View all authors

How to Connect a .NET C# Web API to a MySQL Database — Part 1: Connect with EF Core and a Secure Connection String

· 44 min read
Jagdish Kumawat
Founder @ Dewiride

A Web API needs somewhere to keep its data, and MySQL is one of the most popular places to keep it. This part connects an ASP.NET Core minimal API, written in .NET 10 and C#, to MySQL 9.7 through Entity Framework Core. It keeps the password out of the code, encrypts the connection, proves the connection works with a health check, and then looks at that same connection from inside MySQL so you can see exactly what happened.

How to Add Liveness and Readiness Health Checks to a .NET C# Web API

· 9 min read
Jagdish Kumawat
Founder @ Dewiride

A health check is a small endpoint that answers one question: is this API working? Hosting platforms, load balancers and monitoring tools call it every few seconds and act on the answer. This guide adds two of them to a .NET 10 C# minimal API, one that only checks that the API is running and one that also checks the database, and shows their real answers when the database goes down.

How to Store a Connection String in .NET C# with dotnet user-secrets

· 12 min read
Jagdish Kumawat
Founder @ Dewiride

A connection string usually contains a password, and appsettings.json is committed to Git with the rest of your code. .NET's Secret Manager, the dotnet user-secrets command, keeps secrets in a file in your user profile instead, and ASP.NET Core reads them as if they were in appsettings.json. This guide stores a MySQL connection string that way, shows every command with its real output, and explains how the same setting reaches the app outside development.

How to Create a .NET C# Web API Solution with a Class Library

· 19 min read
Jagdish Kumawat
Founder @ Dewiride

A real .NET C# Web API usually isn't one project. It's a solution: the API itself, plus one or more class libraries for code that doesn't belong in the web layer, such as the database code. This guide builds that structure from the command line with .NET 10, adds the settings that production projects use, and fixes the two errors those settings raise on the template's own code.

How to Stop, Start and Remove Docker Compose Containers Without Losing Data

· 7 min read
Jagdish Kumawat
Founder @ Dewiride

Docker Compose has four everyday commands for stopping and starting your containers, and they differ in what they remove. Three of them keep your database's data; one deletes it for good. This guide runs each one against a real MySQL database and proves the data is still there afterwards, so you know which command to reach for.

How to Check if a MySQL Connection Uses TLS

· 8 min read
Jagdish Kumawat
Founder @ Dewiride

An encrypted connection keeps your password and your data private on the way to MySQL. MySQL 9.7 sets up encryption by itself and uses it whenever it can, but the mysql client in Docker can show SSL: Not in use, and that is fine. This guide shows how to check any connection, why a Unix socket is different, and how to insist on encryption.

How to Check the MySQL Character Set and Collation

· 8 min read
Jagdish Kumawat
Founder @ Dewiride

The character set decides which characters MySQL can store, and the collation decides how it compares and sorts them. Get them wrong and emoji fail to save, or café and cafe turn out to be "equal" when you didn't expect it. This guide checks both at the server, database and connection level, and proves what the default utf8mb4_0900_ai_ci really does.

How to Check the MySQL Version

· 6 min read
Jagdish Kumawat
Founder @ Dewiride

Before you follow a guide, report a bug or plan an upgrade, you need to know exactly which MySQL you're talking to. MySQL tells you in several places, and one of them works without signing in at all. This guide shows five ways, with real output from MySQL 9.7.4 in Docker, and the one place where the version you see can mislead you.

How to Connect to MySQL in a Docker Container with the mysql Client

· 11 min read
Jagdish Kumawat
Founder @ Dewiride

The official MySQL Docker image already contains the mysql command-line client, so you don't need to install anything on your computer to run SQL. One docker compose exec command opens the client inside the running container. This guide signs in, runs the first few queries every new database deserves, and shows the small things that confuse beginners.