What happened to AddOrUpdate in EF 7 / Core?

后端 未结 11 1276
暖寄归人
暖寄归人 2020-12-16 09:30

I\'m writing a seed method using EntityFramework.Core 7.0.0-rc1-final.

What happened to the AddOrUpdate method of DbSet?

11条回答
  •  无人及你
    2020-12-16 09:48

    I've found a nice solution that allows you specify the property that should match. However, it doesn't take a single entity, but a list in each call. It may give you some hints on how to implement a better version that works like the good-olde one.

    https://github.com/aspnet/MusicStore/blob/7787e963dd0b7293ff95b28dcae92407231e0300/samples/MusicStore/Models/SampleData.cs#L48

    (Code isn't mine)

提交回复
热议问题