Relative Content

Tag Archive for c#sql-serverentity-framework-core

Entity Framework Core not catching exception from stored procedure when thrown from a SQL catch block

We hit this issue in one of our applications so I wrote a simple test console app to reproduce it. I have entity framework calling a SQL Server stored procedure, and when that stored procedure throws an error from the catch block, entity framework does not catch that error. It simply populates the result list with zero items but no error. I discovered that if I remove the try/catch from the stored procedure and throw the same error then EF does in fact catch it. However I need the try/catch as there’s other stuff I need to do there. I’ve seem some related posts where people aren’t actually populating the result set (not calling .ToList() or the like) and people are saying that running async was the issue but I called it synchronously and that didn’t change the outcome.

Unknown transaction timeout EF Core

Executing 4 stored procedures (using .NET 8 + EF Core) always stops due to a transaction timeout after approx. 15 minutes although the transaction scope timeout is set to 1 hour! In addition, the command timeout of the DBContext is set to 45 minutes.

Fetch a list sorted by latest change based on multiple joined columns

I have a Persons table and other tables related – Orders, ContactHistory, Addresses, and Emails.
The Persons table has basic details – name, date of birth, and a few other properties.
The class for the table has collections for the tables referenced by the Persons table, so, I can use them in filters where needed or query referenced.