Error Code: 1822. Failed to add the foreign key constaint. Missing index for constraint

create_user INT UNSIGNED ZEROFILL cannot reference id INT, because these count as different data types for purposes of foreign key reference. Make them the same data type. The only data type difference that is permitted between columns in a foreign key relationship is length of a varchar. For example, VARCHAR(10) can reference VARCHAR(20) or vice-versa. … Read more

Modelling polymorphic associations database-first vs code-first

I personally stick with Database first when using EF on any schema that is this level of complexity. I have had issues with complex schemas in regards to code first. Maybe the newer versions are a little better, but worrying how to try and code complex relationships seems less straight forward then allowing the engine … Read more

MySQL foreign key to allow NULL?

You can solve this by allowing NULL in the foreign key column tblImageFlags.resolutionTypeID. PS Bonus points to whomever tells me whether, in the case of databases, it’s “indexes” or “indices”. The plural of index should be indexes. According to “Modern American Usage” by Bryan A. Garner: For ordinary purposes, indexes is the preferable plural, not … Read more