How to seed data with AddOrUpdate with a complex key in EF 4.3

后端 未结 2 2040
盖世英雄少女心
盖世英雄少女心 2020-12-12 14:32

I am trying to seed a development database with some test data.

I have used context.People.AddOrUpdate(p => p.Id, people)); with much success.

<
相关标签:
2条回答
  • 2020-12-12 15:23

    If you got Only primitive types or enumeration types are supported in this context. because of using navigation property - consider adding foreign key property directly to the entity (maybe only with getter) and use it as Ladislav Mrnka proposed.

    0 讨论(0)
  • 2020-12-12 15:31

    Try this:

    context.People.AddOrUpdate(p => new { p.FirstName, p.LastName }, people);
    
    0 讨论(0)
提交回复
热议问题