Skip to main content

273 posts tagged with "Fixes"

Fixes for Common Issues and Errors

View All Tags

Fixed: MySQL Rounds a Decimal Like 9.999 to 10.00 Without an Error (Note 1265: Data truncated for column)

· 7 min read
Jagdish Kumawat
Founder @ Dewiride

I sent a product price of 9.999 to my API, and it answered 201 Created with a price of 10.00. No error, no warning: MySQL rounded the amount to fit its DECIMAL(12,2) column, even in strict mode, and raised only a note that EF Core never shows. For money, silently changing the number isn't acceptable, so the API now refuses it.

Fixed: "Data too long for column 'Name' at row 1" When Saving with EF Core and MySQL

· 7 min read
Jagdish Kumawat
Founder @ Dewiride

A long category name made my API answer 500, with Data too long for column 'Name' at row 1 in the log. MySQL was right to refuse it: the column is varchar(100), and the name had 101 characters. The problem was that the request got as far as MySQL at all. A validation attribute stops it first, and the client gets an answer it can act on.

Fixed: "Unknown column 'p.Version' in 'field list'" with EF Core and MySQL

· 7 min read
Jagdish Kumawat
Founder @ Dewiride

Right after I added a property to an EF Core entity, every request that touched that table answered 500, and the log said MySqlException: Unknown column 'p.Version' in 'field list'. The code built without a problem, because the C# was fine. The table simply didn't have that column yet: changing the class doesn't change the database until a migration does.

Fixed: "Unable to create a 'DbContext' of type 'InventoryDbContext'. The exception 'Unable to resolve service for type DbContextOptions' was thrown" in EF Core

· 7 min read
Jagdish Kumawat
Founder @ Dewiride

Unable to create a 'DbContext' of type 'Dewiride.Inventory.Data.InventoryDbContext'. The exception 'Unable to resolve service for type 'Microsoft.EntityFrameworkCore.DbContextOptions`1[Dewiride.Inventory.Data.InventoryDbContext]' while attempting to activate 'Dewiride.Inventory.Data.InventoryDbContext'.' was thrown while attempting to create an instance. The useful part is the line printed just before it: the app's own startup code had failed, so EF Core's tools couldn't get the DbContext the normal way. Here's how I ran into it with a migrations bundle, why --connection didn't help, and the fix.

Fixed: "NU1608: Pomelo.EntityFrameworkCore.MySql 9.0.0 requires Microsoft.EntityFrameworkCore.Relational (>= 9.0.0 && <= 9.0.999) but version 10.0.14 was resolved"

· 7 min read
Jagdish Kumawat
Founder @ Dewiride

NU1608: Detected package version outside of dependency constraint: Pomelo.EntityFrameworkCore.MySql 9.0.0 requires Microsoft.EntityFrameworkCore.Relational (>= 9.0.0 && <= 9.0.999) but version Microsoft.EntityFrameworkCore.Relational 10.0.14 was resolved. The message spells out the problem: the newest Pomelo MySQL provider is built for EF Core 9, and the project runs EF Core 10. That isn't a version to nudge; it's a provider that doesn't support your EF Core yet.

Fixed: "dotnet package update --vulnerable: error: Restore failed. Unhandled exception: Specified method is not supported."

· 7 min read
Jagdish Kumawat
Founder @ Dewiride

dotnet package update --vulnerable is .NET 10's way to move vulnerable packages to a fixed version in one command. In my solution it printed error: Restore failed, then Unhandled exception: Specified method is not supported., and stopped. The crash message is misleading; the cause is documented: the command restores to do its work, and TreatWarningsAsErrors turned NuGet's own vulnerability warning into a restore error.