//Post public async Task <OperationModel> AddOperation(OperationModel anOperation) { var theOperEntityToAdd = anOperation.ToEntity(); var theMostRecentId = await context.Operation.MaxAsync(i => i.OperationId); var theOperationGroup = await context.OperationGroup.FirstOrDefaultAsync(i => i.OperGroupId == anOperation.Group.Id); theOperEntityToAdd.OperationId = theMostRecentId + 1; theOperEntityToAdd.OperGroup = theOperationGroup; context.Add(theOperEntityToAdd); await context.SaveChangesAsync(); return(theOperEntityToAdd.ToModel()); }