A set of applications and libraries developed on the .NET 5. The main task of which is to control and account for the passage of people or employees through door controllers by using cards.
Microsoft.EntityFrameworkCore.DbUpdateException
HResult=0x80131500
Message=An error occurred while updating the entries. See the inner exception for details.
Source=Microsoft.EntityFrameworkCore.Relational
StackTrace:
at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.Execute(IRelationalConnection connection)
at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.Execute(DbContext _, ValueTuple2 parameters) at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.Execute[TState,TResult](TState state, Func3 operation, Func3 verifySucceeded) at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.Execute(IEnumerable1 commandBatches, IRelationalConnection connection)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(IReadOnlyList`1 entriesToSave)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(Boolean acceptAllChangesOnSuccess)
at Microsoft.EntityFrameworkCore.DbContext.SaveChanges(Boolean acceptAllChangesOnSuccess)
at SecurityDoors.BusinessLogicLayer.Implementations.PersonRepository.Save(Person item) in C:\Users\Fedechkin Alexey\Source\Repos\Security-Doors\SecurityDoors.BusinessLogicLayer\Implementations\PersonRepository.cs:line 74
at SecurityDoors.RemoteControl.Database.AddPerson(Person person) in C:\Users\Fedechkin Alexey\Source\Repos\Security-Doors\SecurityDoors.RemoteControl\Database.cs:line 36
at SecurityDoors.RemoteControl.Command.addPerson() in C:\Users\Fedechkin Alexey\Source\Repos\Security-Doors\SecurityDoors.RemoteControl\cli\Command.cs:line 72
at SecurityDoors.RemoteControl.cli.Cli.run() in C:\Users\Fedechkin Alexey\Source\Repos\Security-Doors\SecurityDoors.RemoteControl\cli\Cli.cs:line 32
at SecurityDoors.RemoteControl.Program.Main(String[] args) in C:\Users\Fedechkin Alexey\Source\Repos\Security-Doors\SecurityDoors.RemoteControl\Program.cs:line 11
Inner Exception 1:
SqlException: Cannot insert explicit value for identity column in table 'Cards' when IDENTITY_INSERT is set to OFF.
ошибка возникает когда я пытаюсь сохранить Person у которого в качестве значения поля Card задан вывод метода GetCardById с параметров -1