cannot update identity column in Entity Framework Core

前端 未结 7 680
感情败类
感情败类 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条回答
  • 2021-01-04 01:27

    I found this other solution (I am using .NET Core 2.1):

    using System;
    using System.Collections.Generic;
    using System.Diagnostics.Tracing;
    using System.Linq;
    using System.Security.Cryptography.X509Certificates;
    using System.Threading.Tasks;
    using Microsoft.EntityFrameworkCore;
    using Microsoft.Extensions.Caching.Memory;
    using YetAnotherERP.Data;
    using YetAnotherERP.Entities;
    using YetAnotherERP.Exceptions;
    using YetAnotherERP.Utils;
    
    namespace YetAnotherERP.Services
    {
        public class EmployeeRepository : IEmployeeRepository
        {
    
        private DataContext _context;
    
        public EmployeeRepository(DataContext dataContext)
        {
            _context = dataContext;
        }
    
    
        ....
    
    
                public async Task UpdateEmployee(Employee employee)
            {
                _context.Update(employee).Property(x=>x.Id).IsModified = false;
                _context.SaveChanges();
            }
    
    0 讨论(0)
提交回复
热议问题