I've got MySql database and ASP.NET Core 2.2 app working okay on my local Windows machine. But when I publish them to Ubuntu 18.10 and try to insert any child record for my User
, I get the following exception:
MySql.Data.MySqlClient.MySqlException (0x80004005): Cannot add or update a child row: a foreign key constraint fils (
library
.Books
, CONSTRAINTFK_Books_Users_UserId
FOREIGN KEY (UserId
) REFERENCESusers
(id
))
Before creating a book
, the user is already created and has Id
.
Both tables use InnoDB engine.
Both tables have identical collation.
This problem happens for all the models the User has connections with.
The deployed database was populated with my local database dump.
Database Provider: Pomelo.EntityFrameworkCore.MySql
I think the problem must be in some difference between Windows and Ubuntu. But I don't know what it can be except different case sensitivity, which turns out is not a problem here as I tried different lower_case_table_names
configurations.
The problem is with mysqldump
. As mentioned in the question, the local db was exported and then imported into production environment. But local and production MySQL versions were different. Some table and column names were exported in lowercase.
The solution was to rename all the broken names to the valid ones and only then import the dump. Or if you do not want to so each time, dump your local database with mysqldump
version which corresponds to the on on the production database.
User contributions licensed under CC BY-SA 3.0