Rename
Rename
Explore posts from servers
CC#
Created by Rename on 4/20/2025 in #help
EF Core 8: System.InvalidOperationException: 'The instance of entity type cannot be tracked..
what I'm saving actually is very simple, at that point just an update of a table's column. but I need to load all that data because we need to do quite some checks before the save. the website was initially in .NET 4.6.2, a legacy app and I've been moving it .NET 8 and refactoring along the way
8 replies
CC#
Created by Rename on 4/20/2025 in #help
EF Core 8: System.InvalidOperationException: 'The instance of entity type cannot be tracked..
yeah actually I was assigning navigation properties as I've got rich domain entities filled with a lot of logic. I was able to fix it by changing my update method to this:
public TEntity Update(TEntity entity)
{
dbContext.Entry(entity).State = EntityState.Modified; //this will only update the entity and not it's navigation properties
//var entry = dbContext.Set<TEntity>().Update(entity);
dbContext.SaveChanges();
return entity;
}
public TEntity Update(TEntity entity)
{
dbContext.Entry(entity).State = EntityState.Modified; //this will only update the entity and not it's navigation properties
//var entry = dbContext.Set<TEntity>().Update(entity);
dbContext.SaveChanges();
return entity;
}
otherwise I'm guessing it was mistakenly tracking navigation properties and thinking those got modified also. I guess this gives me more control over what I want changed so I'll likely be keeping it this way. if anyone happens to have a better idea I'd love to hear it 😅
8 replies
CC#
Created by Rename on 4/20/2025 in #help
EF Core 8: System.InvalidOperationException: 'The instance of entity type cannot be tracked..
well as far as I can tell I am awaiting properly, from my endpoint I call a commandHandler service which begins like so:
protected override async Task<OutputPostUpdateWorkWeekShift> OnExecute(InputPostUpdateWorkWeekShift input)
{
//Here, dbContext has no entries

var staffMember = (await staffMemberRepository.GetForWorkWeek(input.StaffMemberId)).FirstOrDefault()
?? throw new SmartRotaException(StatusCodes.Status404NotFound, "There was no staff member found with the provided ID.");

//Here dbContext has a lot of uneccessary entries.
...rest of the code
protected override async Task<OutputPostUpdateWorkWeekShift> OnExecute(InputPostUpdateWorkWeekShift input)
{
//Here, dbContext has no entries

var staffMember = (await staffMemberRepository.GetForWorkWeek(input.StaffMemberId)).FirstOrDefault()
?? throw new SmartRotaException(StatusCodes.Status404NotFound, "There was no staff member found with the provided ID.");

//Here dbContext has a lot of uneccessary entries.
...rest of the code
and the GetForWorkWeek method is in the text file (sorry it's a bit long but simple)
8 replies
CDCloudflare Developers
Created by Rename on 4/15/2025 in #general-help
Issue with CloudFlare response
I'm also not sure the headers from the cloudflare request are quite right (Connection close): I've removed some uneccessary ones
Cache-Control: max-age=0
Connection: close
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Accept-Encoding: gzip, br
Accept-Language: en-GB,en-US;q=0.9,en;q=0.8
Cookie: ...
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36
sec-fetch-dest: document
cf-ipcontinent: EU
x-forwarded-proto: https
cdn-loop: cloudflare; loops=1
cf-visitor: {&quot;scheme&quot;:&quot;https&quot;}
priority: u=0, i
upgrade-insecure-requests: 1
sec-fetch-site: none
sec-fetch-mode: navigate
sec-fetch-user: ?1
Cache-Control: max-age=0
Connection: close
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Accept-Encoding: gzip, br
Accept-Language: en-GB,en-US;q=0.9,en;q=0.8
Cookie: ...
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36
sec-fetch-dest: document
cf-ipcontinent: EU
x-forwarded-proto: https
cdn-loop: cloudflare; loops=1
cf-visitor: {&quot;scheme&quot;:&quot;https&quot;}
priority: u=0, i
upgrade-insecure-requests: 1
sec-fetch-site: none
sec-fetch-mode: navigate
sec-fetch-user: ?1
54 replies
CDCloudflare Developers
Created by Rename on 4/15/2025 in #general-help
Issue with CloudFlare response
I was able to get the logs, I guess it was taking some time for them to show up and this is the data I got now, notice the 995 sc-win32-status code of the last request the second and third (last) requests both failed when going through CF with the Bad Gateway error but seems only the third one returned the 995 code which translates to
995 (0x3E3)

The I/O operation has been aborted because of either a thread exit or an application request.
995 (0x3E3)

The I/O operation has been aborted because of either a thread exit or an application request.
the website's timeout limit was 120 seconds, even changed it to 300 but got 995 again when time-taken is 10565(ms)
54 replies
CDCloudflare Developers
Created by Rename on 4/15/2025 in #general-help
Issue with CloudFlare response
they all are HTTP/2 version
54 replies
CDCloudflare Developers
Created by Rename on 4/15/2025 in #general-help
Issue with CloudFlare response
I'll likely have to compare the requests with Wireshark to see if I can find a difference between the CF forwarded one and the one being sent directly
54 replies
CDCloudflare Developers
Created by Rename on 4/15/2025 in #general-help
Issue with CloudFlare response
but this also wouldn't explain why it doesn't fail if I access it directly from the server IP right? or is there an explanation for that I'm missing
54 replies
CDCloudflare Developers
Created by Rename on 4/15/2025 in #general-help
Issue with CloudFlare response
really weird one for sure, considering I don't get any errors or info in Event Viewer, IIS logs or even Sys32/HTTPErr files of the server
54 replies
CDCloudflare Developers
Created by Rename on 4/15/2025 in #general-help
Issue with CloudFlare response
so you got a partial response then it just ended?
54 replies
CDCloudflare Developers
Created by Rename on 4/15/2025 in #general-help
Issue with CloudFlare response
huh strange one for sure, I'll see if I can find something out thank you again
54 replies
CDCloudflare Developers
Created by Rename on 4/15/2025 in #general-help
Issue with CloudFlare response
let me know if I can be of any help
54 replies
CDCloudflare Developers
Created by Rename on 4/15/2025 in #general-help
Issue with CloudFlare response
perfect
54 replies
CDCloudflare Developers
Created by Rename on 4/15/2025 in #general-help
Issue with CloudFlare response
done
54 replies
CDCloudflare Developers
Created by Rename on 4/15/2025 in #general-help
Issue with CloudFlare response
made a request with that header included just now
54 replies
CDCloudflare Developers
Created by Rename on 4/15/2025 in #general-help
Issue with CloudFlare response
just gave it a go again right now, with the same url
54 replies
CDCloudflare Developers
Created by Rename on 4/15/2025 in #general-help
Issue with CloudFlare response
I could retry right now if you're free to look
54 replies
CDCloudflare Developers
Created by Rename on 4/15/2025 in #general-help
Issue with CloudFlare response
you won't be able to access the page since it'll redirect to the login, but if there's anything other info I could give let me know. appreciate both your guys help
54 replies
CDCloudflare Developers
Created by Rename on 4/15/2025 in #general-help
Issue with CloudFlare response
seems I can't create a support ticket with my account so this is the actual URL (with error:
Cloudflare encountered an error processing this request: Bad Gateway
Cloudflare encountered an error processing this request: Bad Gateway
) tested just now: https://hippodromecasino.smartrota.com/site/The-Hippodrome-Casino-Ltd/Gaming-Staff/manager-dashboard/occurrence-list?contractOption=All&occurrenceRule=&occurrenceType=&selectedName=&startDate=15%2f04%2f2025&startDateMax=30%2f04%2f2025
54 replies
CDCloudflare Developers
Created by Rename on 4/15/2025 in #general-help
Issue with CloudFlare response
yep it's only started recently. it actually happened maybe about 2 weeks ago or more, then it resolved on it's own and now it's back again.
54 replies