Category "entity-framework-core"

How to translate this SQL into LINQ, with correlated subquery single table

The raw SQL uses correlated subquery for single table, any possibility to translate this with single LINQ Query? SELECT * From dbo.Products AS P1 WHERE SalePric

Could not load assembly 'CommonBaseData'. Ensure it is referenced by the startup project 'CommonBaseType'

I want create micro service architecture solution so I add some services for my solution. All my services must have one table in my database in there models so

ASP.NET Core MVC. Implementation of the IDataProtectionKeyContext interface

There is a data context: public class OurDbContext : DbContext, IOurDbContext, IDataProtectionKeyContext { public DbSet<Employee> Employees { get; set

TypeLoadException Method 'IsValid' in type in Pomelo.EntityFrameworkCore.MySql.Update does not have an implementation

When I use Pomelo.EntityFrameworkCore.MySql in combination with Microsoft.AspNetCore.Identity I am getting that error. Are my dependencies wrong ? Similar issue

"The instance of entity type cannot be tracked" error when adding detached entity tree

I am unable to add the Deal entity because Buyer and Seller are referencing the same city "City1". I work with detached entities here because I receive the whol

Connect local SQL Server from WSL2 (Ubuntu) [duplicate]

I started to develop a .NET Core Web API application with SQL Server. I use the Windows Subsystem for Linux (I store the files in the Ubuntu s

NET 5 and EF: how to use AddPooledDbContextFactory in liu of DbContext in services

I recently came across AddPooledDbContextFactory concept as part of my NET 5 self-education piece and am keen to implement it properly. However, I am not sure h

How to get navigation properties with [Owned] attribute Tracked in Entity Framework Core

I got EF tracking turned off by default on my project. I got a DB model class UserModel: public class UserModel : BaseAdminDbModel { [Key] p

Is there any way to embed a class Element into a class Element in Entity Framework?

This is my code: namespace MyProject.Models.Database { public class Recipe { public Guid Id { get; set; } = Guid.NewGuid(); public strin

Troubleshooting enums with efcore.pg

Are there any best practices in troubleshooting enums when using with Npgsql.EntityFrameworkCore.PostgreSQL provider? It's just that I don't know where to look

Does automapper support mapping collections with circular references?

I'm using automapper to map collections of incoming DTOs objects and save it all at once using Entity Framework. Everything works perfectly fine till I came acr

Running EF core command 'update database' in .NET core 2.2 app is applying an old migration instead of the current one

I'm working on a .NET Core version 2.2 app (with Angular), which uses EF Core (code first). It's been an existing project for a few years, I've cloned it about

LINQ script class throwing TaskCanceledException Error

I am working on .NET CORE 6 application along with Entity Framework CORE 7. I have class where I have written LINQ script. This is async method. I am not sure w

EF Core Cosmos DB provider doesn't populate id as combination of key and discriminator

I use CosmosDB (Sql Core) + EFCore (3.1.10) + CosmosDb provider (3.1.10). My entity has property Id (starts with capital latter), discrimination is not turned o

Entity Framework Core 2.1 Add Migration System.NullReferenceException: Object reference not set to an instance of an object

We use to get the following error when we try to run add-migration. We use Entity Framework Core 2.1. System.NullReferenceException: Object reference not set to

Microsoft.AspNetCore.Identity.IdentityError: "InvalidUserName"

I did default Megration with User model, added only my two custom properties. EF created standard flow of tables. And my AspNetUsers table As you can see User

Adding dynamically a DbSet<TEntity> in DbContext class

Is there a way to add DbSet<TEntity> Property in DbContext class at runtime without passing through OnModelCreating ?

Why does Resolver behave differently in Query vs Mutation?

I've been struggling with the issue/behaviour described below for while now and can't seem to figure out what's going on. This is all based on inherited/adapted

SELECT result map to entity in Dynamic Linq in Entity Framework Core

I have a Linq query which is selecting 2 columns(that can be any 2 from all columns) dynamically based on some condition.I need to map the query result in to be

Ignore global query filter for joined entities

Global query filters are very handy when implementing tenant and soft deletion features. But my problem is is that when i write a query with joins, for instance