Category "entity-framework-core"

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

The instance of the entity type cannot be tracked because another instance with the keyvalue is being tracked

I am basically trying to implement CRUD using EntityFrameWork core and .Net core 3.1. I have an issue with my update operation where I am not able update the co

Avoid unnecessary include statements in SQL database query for ASP.NET Core

There are some times where I have a user and would like to check whether they are in the organization that owns the item they are trying to access. Let's say th

Where to call EF Core Migrate in web API startup class?

I'm trying to process DB migrations during application startup in a Azure-hosted web API. However, no matter where I try to put it, I get the exception: ObjectD

Entity framework core TPH query across different subtype properties

I'm using EF core TPH inheritance to model some data and I'm trying to write a query that will query across different subtypes. My current attempt at writing a

How to override List property in EF Core 6?

I have a problem, in database I have an object of class Catalog with 3 elements in CatalogUsers. I want to replace that list with 2 element list being the orgin

Use JSON_ARRAYAGG with Entity Framework Core

I am trying to use JSON_ARRAYAGG(JSON_OBJECT(...)) in Entity Framework Core but I don't know much how to trick Entity Framework Core to use this function with a

How skip some migrations in ef core?

I had some changes in my ef context and I added new Migraions dotnet ef migrations add changed98112601 then I run the below command dotnet ef database upd