diff --git a/SCHALE.GameServer/Controllers/Api/ProtocolHandlers/Echelon.cs b/SCHALE.GameServer/Controllers/Api/ProtocolHandlers/Echelon.cs index 8357395..ec6b436 100644 --- a/SCHALE.GameServer/Controllers/Api/ProtocolHandlers/Echelon.cs +++ b/SCHALE.GameServer/Controllers/Api/ProtocolHandlers/Echelon.cs @@ -1,4 +1,5 @@ using AutoMapper; +using Microsoft.EntityFrameworkCore; using SCHALE.Common.Database; using SCHALE.Common.Database.ModelExtensions; using SCHALE.Common.FlatData; @@ -12,13 +13,14 @@ namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers ISessionKeyService _sessionKeyService, SCHALEContext _context, ExcelTableService _excelTableService, + ILogger _logger, IMapper _mapper ) : ProtocolHandlerBase(protocolHandlerFactory) { private readonly ISessionKeyService sessionKeyService = _sessionKeyService; private readonly SCHALEContext context = _context; private readonly ExcelTableService excelTableService = _excelTableService; - + private readonly ILogger logger = _logger; private readonly IMapper mapper = _mapper; [ProtocolHandler(Protocol.Echelon_List)] @@ -43,8 +45,10 @@ namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers context.Echelons.Add(db); else { - db.ServerId = old.ServerId; + // https://github.com/dotnet/efcore/issues/9156 + context.Entry(old).State = EntityState.Detached; mapper.Map(db, old); + context.Entry(old).State = EntityState.Modified; } context.SaveChanges(); return new EchelonSaveResponse() { EchelonDB = db, }; diff --git a/SCHALE.GameServer/Services/AutoMapper.cs b/SCHALE.GameServer/Services/AutoMapper.cs index 48b2675..e040326 100644 --- a/SCHALE.GameServer/Services/AutoMapper.cs +++ b/SCHALE.GameServer/Services/AutoMapper.cs @@ -7,7 +7,7 @@ namespace SCHALE.GameServer.Services { public MappingProfile() { - CreateMap(); + CreateMap().ForMember(x => x.ServerId, opt => opt.Ignore()); } } }