Workaround LAST_INSERT_ID and CAST limitations by making all primary keys unsigned bigint. Workaround LAST_INSERT_ID signed/unsigned inconsistency between 5.5 and 5.6 by using Convert.ToUInt64 instead of casts.