INSERT … ON DUPLICATE KEY (do nothing)

I have a table with a unique key for two columns: CREATE TABLE `xpo`.`user_permanent_gift` ( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT , `fb_user_id` INT UNSIGNED NOT NULL , `gift_id` INT UNSIGNED NOT NULL , `purchase_timestamp` TIMESTAMP NULL DEFAULT now() , PRIMARY KEY (`id`) , UNIQUE INDEX `user_gift_UNIQUE` (`fb_user_id` ASC, `gift_id` ASC) ); I want to … Read more

Unique Key constraints for multiple columns in Entity Framework

I’m using Entity Framework 5.0 Code First; public class Entity { [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] public string EntityId { get; set;} public int FirstColumn { get; set;} public int SecondColumn { get; set;} } I want to make the combination between FirstColumn and SecondColumn as unique. Example: Id FirstColumn SecondColumn 1 1 1 = OK 2 2 … Read more