Skip to main content

200 posts tagged with "Errors"

Common Errors and Troubleshooting in Programming

View All Tags

Fixed: "The model for context has pending changes. Add a new migration before updating the database." in EF Core

· 7 min read
Jagdish Kumawat
Founder @ Dewiride

dotnet ef database update printed The model for context 'InventoryDbContext' has pending changes., then No migrations were applied, then Done., and exited with code 0. My new column wasn't in MySQL. That message has two possible causes, and with this provider it won't stop a script, so it's easy to miss.

Fixed: "The migration 'AddProductVersion' was not found." with dotnet ef --no-build

· 5 min read
Jagdish Kumawat
Founder @ Dewiride

I created a migration, and the very next command said The migration 'AddProductVersion' was not found. The file was right there in the Migrations folder. The cause was a flag I'd added to save a few seconds: --no-build makes the EF Core tools use the last compiled DLL, and that DLL was older than the migration.

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.