Prevent duplicate records with seed

Prevent duplicate records when you use seed method in migration. Originally in Migrations/Configuration.cs we can use: context.People.AddOrUpdate( p => p.FullName, new Person { FullName = “Andrew Peters” }, new Person { FullName = “Brice Lambson” }, new Person { FullName = “Rowan Miller” } ); But when we configure adding record (like sample above) every […]

Some commands: Enable Database Migrations

If you want to apply database migrations in your project just type in NuGat Console those command: enable-migrations After every change of structure in your database model need to called at migration command with your custom migration name: add-migration <name-of-change> Now it’s time to¬†database update command: update-database and for the end – if something went […]