Spaxter
Explore posts from servers✅ Transient DbContext vs DbContextFactory
In EF Core, what is the difference between registering a transient
DbContext
vs a DbContextFactory
for DI?
In both cases the DbContext will be created on-demand and disposed when the operation is completed, right? Are there any clear indications on when to use which?4 replies
✅ EF Core - Not getting updated data from PostgreSQL table
I have the following method in my
DbService.cs
Which returns a unix timestamp from a postgres table. However if I manually change the data in the column to a completely different number and call the method again I still get the old value prior to my manual change, even after restarting my app. Am I doing something wrong?6 replies
Method on DI service doesn't do anything
Hello, I have a .NET app using Dependency Injection. One of the services I am injecting is a service for handling database insertions etc. Right now I have two methods on this class, one of them works perfectly fine but the other doesn't do anything when called.
This is the method:
And when calling them like this, I only see the debug logs from the second method. The first one doesn't seem to run at all despite being called
20 replies
DbContextFactory check for valid connection on app startup
I have a .NET app where I'm currently using EF Core's DbContextFactory with Postgres. However I noticed that no matter what host I set in my connection string the app starts normally and no errors are thrown. Is it possible to validate the connection at startup?
2 replies
✅ EF Core long running query causing concurrency issues
Hello. I have a .NET application that uses a DbContext with PostgreSQL. To test the performance of my app, I added a million rows to one of the tables.
I noticed that it takes a pretty long time to fetch all of these rows, and if I run the method to get all the rows again before the previous query finishes, it throws the following exception:
System.InvalidOperationException: A second operation was started on this context instance before a previous operation completed. This is usually caused by different threads concurrently using the same instance of DbContext.
This is an example of how it is set up currently:
9 replies
✅ launchSettings.json being ignored completely
All of a sudden, my .NET Visual Studio project has stopped respecting my
launchSettings.json
file. No matter what profile I run the app with, it uses the ports 5000
and 5001
. I have no idea how this happened or why.
launchSettings.json
10 replies