2,594 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
4
votes
3
answers
227
views
Getting ORA-00933 with EF Core when running queries
I've a table in my Oracle 11g database where the primary column has the name INT of data type NUMBER. The column is mapped to a property named Id in my entity.
I'm using EF Core v7 to connect to the ...
1
vote
0
answers
71
views
ASP.NET Core background/singleton service — how should I access DbContext safely? [duplicate]
I have an ASP.NET Core 8 app with a long-lived service that refreshes an in-memory cache on a timer. I registered the service as a singleton (it’s a hosted background worker), and it needs to query ...
0
votes
1
answer
96
views
Why DBContecxt.Database.Exists() becomes extremely slow when data source (IP) is wrong, but still fast when other credentials incorrect? [duplicate]
I am using EF 6 DbContext.Database.Exists() method, i.e. its return value true/false, to detect if a given DB is available. If it is, I pull and process data, if not, I enter a message into the log ...
2
votes
1
answer
86
views
Using the same DbContext class definition for both a DbContext object and an IDbContextFactory object
I am using .NET 8 and Oracle EF Core. In my application, I need to use both AddDbContext<MyDbContext>() for normal per-request operations and AddPooledDbContextFactory<MyDbContext>() for ...
1
vote
1
answer
45
views
How to get data when need to join table and only select the latest item
I have this query in SQL:
SELECT c.CompanyName,
(
SELECT TOP 1
ct.CompanyTypeID
FROM CompanyType AS ct
WHERE ct.CompanyID=c....
1
vote
0
answers
86
views
Generic context factory using LightInject in .NET 8 with generics
I am creating a library for our department to access multiple resources. Each resource type is in its own project inside the large solution. Each project will be built into its own NuGet package and ...
0
votes
0
answers
67
views
EF Core throw an exception related to a schema where the queried entity is from another schema
I get this exception:
The entity type 'TblCentrale' requires a primary key to be defined.
If you intended to use a keyless entity type, call 'HasNoKey' in 'OnModelCreating'.
This is the code in ...
0
votes
1
answer
82
views
How is a scoped DbContext's connection handled?
When I implement an ASP.NET Core application, I may have several middlewares that must interact with the database in order to check something. All of them, and also the final endpoint, share a scoped ...
0
votes
0
answers
61
views
DbContext lifetime / dependency injection issue running multiple Web API tests in .NET 8
I've run into a sticky little problem with my Visual Studio 2022 Web API test project. All of tests run successfully separately (one at a time), but when I try to run them all together (bulk) I get ...
1
vote
0
answers
83
views
Cannot enlist in the transaction because a local transaction is in progress on the connection. Finish local transaction and retry
I am trying to use TransactionScope to make my db context operations spread across different files run under one transaction, so all or none save should happen.
The problem is it is giving me this ...
0
votes
2
answers
80
views
The instance of entity type 'VALUE' cannot be tracked because another instance with the same key value for {'OrderId'} is already being tracked
I decided to add models to work with the database.
That's how it was and working
public sealed class DatabaseContext : DbContext
{
public DbSet<Payment> Payments { get; set; } = null!;
I ...
0
votes
0
answers
70
views
Variable context in ASP.NET MVC (C#)
In my ASP.NET MVC project (written in C#), I want to use the right DbContext according some value from some condition. That DbContext should be available for all the methods of the controller. To do ...
0
votes
0
answers
44
views
.NET Framework & Entity Framework : not saving entity's nested collection related with foreign key
I'm having some issues with Entity Framework on .NET Framework. My app is designed as such:
I have my class that inherits from DbContext and I have this property:
public DbSet<User> Users { get; ...
1
vote
1
answer
190
views
How to dynamically access tables across multiple databases using Entity Framework Core?
In my company, we have a system with the following structure:
Moldable hosts: servers are defined by their IP addresses
Moldable databases: each database is created based on a country code
Company-...
0
votes
1
answer
93
views
Dataflow thread safe db context
My app receives multiple files (50 files, each file with 1000 rows) and processes them in Dataflow blocks. In one of the blocks UploadToDatabaseBlock, I set MaxDegreeOfParalellism to 8. This creates ...