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

Fixed: "BLOB, TEXT, GEOMETRY or JSON column 'Description' can't have a default value" When Making an EF Core Column Required on MySQL

· 8 min read
Jagdish Kumawat
Founder @ Dewiride

I changed a C# property from string? to a required string, and the EF Core migration for it failed on MySQL with "BLOB, TEXT, GEOMETRY or JSON column 'Description' can't have a default value". EF Core had added DEFAULT '' to fill the rows that were empty, and MySQL doesn't accept a plain default on a longtext column. The fix is a two-line edit to the migration: fill the empty rows yourself, then make the column NOT NULL without a default.

Fixed: "Data too long for column 'Name' at row 2" When Applying an EF Core Migration to MySQL

· 8 min read
Jagdish Kumawat
Founder @ Dewiride

EF Core warned me that a migration "may result in the loss of data", and on MySQL that warning turned into an error: "Data too long for column 'Name' at row 2". Worse, the migration had already changed one column before it failed. This post shows how to find the values that don't fit, see exactly what the failed migration did, fix the data, and apply the migration again.

Fixed: "ERROR 1146 (42S02): Table 'inventory.Products' doesn't exist" in MySQL

· 6 min read
Jagdish Kumawat
Founder @ Dewiride

ERROR 1146 (42S02): Table '…' doesn't exist usually means exactly that. But sometimes the table is right there, just with different capital letters, and MySQL on Linux treats Products and products as two different names. This post shows the failing query, the setting that causes it, and how to choose table names that work the same on Linux, Windows and macOS.

Fixed: "ERROR 1264 (22003): Out of range value for column 'UnitPrice' at row 1" in MySQL

· 8 min read
Jagdish Kumawat
Founder @ Dewiride

ERROR 1264 (22003): Out of range value for column means the number you're saving doesn't fit the column's type. For a DECIMAL column, the limit isn't the number of decimals, which MySQL quietly rounds, but the number of digits before the decimal point. This post finds a column's exact limit, shows the difference between a value that's rounded and one that's refused, and fixes it from both sides: the column and the input.

Fixed: "ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint fails" in MySQL

· 7 min read
Jagdish Kumawat
Founder @ Dewiride

ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint fails means you inserted or updated a row that points at a parent which doesn't exist. I got it from my own mistake: I guessed that a new category had Id 3, because it was the third one I'd created. It wasn't. This post shows why the guess was wrong, how to find the right Id, how to insert without guessing, and how to answer 400 Bad Request from a .NET C# API.

Fixed: "ERROR 1451 (23000): Cannot delete or update a parent row: a foreign key constraint fails" in MySQL

· 8 min read
Jagdish Kumawat
Founder @ Dewiride

ERROR 1451 (23000): Cannot delete or update a parent row: a foreign key constraint fails means the row you're deleting is still in use: another table points at it through a foreign key, and that foreign key forbids the delete. The message even tells you which table and column. This post reads it piece by piece, finds the rows that block the delete, shows two ways to clear them, and turns the error into a 409 Conflict in a .NET C# API.

Fixed: "ERROR 1062 (23000): Duplicate entry 'adapters' for key 'categories.IX_categories_Name'" in MySQL

· 8 min read
Jagdish Kumawat
Founder @ Dewiride

ERROR 1062 (23000): Duplicate entry … for key … means a unique index refused a value that already exists. Usually that's the index doing its job. The surprise in my case was which value counted as a duplicate: MySQL refused adapters because Adapters was already there. This post explains why, how to choose the behaviour you want, and how to handle the error cleanly in MySQL and in a .NET C# API.

Fixed: "ERROR 3819 (HY000): Check constraint 'CK_products_UnitPrice' is violated." in MySQL

· 8 min read
Jagdish Kumawat
Founder @ Dewiride

MySQL enforces CHECK constraints, and it tells you when a row breaks one: ERROR 3819 (HY000): Check constraint '…' is violated. I met it twice in one afternoon: first when an EF Core migration tried to add constraints to a table that already held a bad row, then when a new row broke the rule. Both have the same cause and the same kind of fix, and in a .NET C# API the error can become a clear 400 Bad Request instead of a crash.

Fixed: "ERROR 1064 (42000): You have an error in your SQL syntax … near 'IF NOT EXISTS(SELECT * FROM `__EFMigrationsHistory`'" in an EF Core Idempotent Migration Script

· 13 min read
Jagdish Kumawat
Founder @ Dewiride

An EF Core migration script made with dotnet ef migrations script --idempotent failed in MySQL 9.7 at line 8 with ERROR 1064 (42000). Oracle's EF Core provider for MySQL writes the script's "skip what's already applied" checks as SQL Server-style IF NOT EXISTS(…) BEGIN … END blocks, and MySQL accepts that kind of block only inside stored procedures and other stored programs. The fix is a plain script that starts at the database's last applied migration.

Fixed: "[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate" in Python on macOS

· 7 min read
Jagdish Kumawat
Founder @ Dewiride

A Python script on my Mac couldn't open an HTTPS address: ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate. curl opened the same address without a problem. Python from python.org brings its own OpenSSL, which doesn't use the Mac's certificates, and the fix is a script that comes with it: Install Certificates.