Entity Framework Code First AddOrUpdate method insert Duplicate values

后端 未结 13 1222
清酒与你
清酒与你 2020-12-01 08:52

I have simple entity:

public class Hall
{
    [Key]
    public int Id {get; set;}

    public string Name [get; set;}
}

Then in the S

13条回答
  •  日久生厌
    2020-12-01 09:42

    I think it's likely that you need to back out existing database migrations (i.e. start your database from scratch) with something like Update-Database TargetMigration:0 followed by Update-Database.

    As it is, you're not dropping the existing table or values, you're just add/updating those values. That needs to happen in order to get your desired result.

提交回复
热议问题