Saturday 27 July 2013

Entity Framework Code First Seeding with Related Data

A quick tip I stumbled upon while working on an MVC application using Entity Framework Code First.

In order to Seed Related Data when using Entity Framework Code First, it’s important to give items temporary ID’s before calling the seed method. Otherwise, when the database is seeded you will end up with Conflicted Inserts