Skip to main content

8 posts tagged with "Web API"

Building HTTP Web APIs That Other Apps Call

View All Tags

How to Connect a .NET C# Web API to a MySQL Database — Part 2: Create MySQL Tables with EF Core Migrations

· 45 min read
Jagdish Kumawat
Founder @ Dewiride

Part 1 connected a .NET C# Web API to MySQL, but the database is still empty. This part describes the inventory data as C# classes and lets EF Core migrations create the matching MySQL tables, with the column types, keys, indexes and constraints you'd otherwise write by hand. You'll read the SQL before it runs, apply it, change the model and add a second migration, and then check every table from inside MySQL.

How to Run an ASP.NET Core App on a Fixed Port (launchSettings.json, --urls and ASPNETCORE_HTTP_PORTS)

· 7 min read
Jagdish Kumawat
Founder @ Dewiride

A new ASP.NET Core project listens on a port the template picked at random, such as 5255. That's fine until you write it into a .http file, a README or another app's settings, and a teammate's copy uses a different one. There are three ways to choose the port, for different situations. This guide tries each one on the same .NET 10 Web API and shows which one wins.

How to Save and Read DateTime as UTC with EF Core and MySQL

· 9 min read
Jagdish Kumawat
Founder @ Dewiride

You save DateTime.UtcNow with EF Core, read it back from MySQL, and the Z that marks UTC is gone from your API's JSON. Worse, a DateTime.Now slipped in somewhere is stored as local time, hours away from everything else. This guide shows both problems with a real .NET C# Web API and MySQL 9.7, explains why they happen, and fixes them for every DateTime in the model with one small value converter.

Fixed: "System.IO.IOException: Failed to bind to address http://127.0.0.1:5190: address already in use." in ASP.NET Core

· 7 min read
Jagdish Kumawat
Founder @ Dewiride

System.IO.IOException: Failed to bind to address http://127.0.0.1:5190: address already in use. The app is fine; the port isn't free. Something else, very often another copy of the same app, is already listening on it. Here's how I found what held the port, stopped it cleanly, and when to pick another port instead.

Fixed: "DbUpdateException: Could not save changes. Please configure your entity type accordingly." with EF Core and MySQL

· 12 min read
Jagdish Kumawat
Founder @ Dewiride

Four different mistakes, one message: Microsoft.EntityFrameworkCore.DbUpdateException: Could not save changes. Please configure your entity type accordingly. A duplicate name, a negative price, a missing category and a blocked delete all produced it, through Oracle's MySQL provider for EF Core. Nothing was wrong with any entity type's configuration. The real reason sits one line lower, in the inner MySqlException, and its error number is what your code should handle.

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

· 42 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 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.

Stay Updated

Subscribe to our newsletter for the latest tutorials, tech insights, and developer news.

By subscribing, you agree to our privacy policy. Unsubscribe at any time.