cannot update identity column in Entity Framework Core

前端 未结 7 756
感情败类
感情败类 2021-01-04 00:52

I\'ve added a separate Identification to the AspNetUsers table called NumericId that will serve along with the GUID like ID that ASP has for default.

I\'ve added the

7条回答
  •  Happy的楠姐
    2021-01-04 01:02

    Per the discussion on GitHub surrounding this issue, for EF Core 2.0 we needed to use both lines suggested in other posts.

    for Entity framework core 2.0 , The "IsReadOnlyAfterSave" property is deprecated. Use following:

    builder.Property(p => p.Id)
        .UseSqlServerIdentityColumn();
    
    builder.Property(p => p.Id)
        .Metadata.AfterSaveBehavior = PropertySaveBehavior.Ignore;
    

提交回复
热议问题