Category "entity-framework-core"

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

Dynamic container name when mapping Cosmos DB using EF Core

I have an OData endpoint which query collection of Cosmos entity. The Cosmos DB container name is dynamic so that I cannot use entity.ToContainer("<container

How to seed in Entity Framework Core 3.0?

I am trying seed the database with some data, using ASP.NET CORE 3.0 and EF Core. I've created my DbContext and according to documentation, online sources, or

why dbcontext.savechanges() donot clear tracked entites of this dbcontext in efcore

I have an error on update entities use efcore and automapper: Entity cannot be tracked because another instance is with the same key value I saw some answers an

.Net Core, Entity Framework Core not working on Linux server

I deployed a test console app to a linux server and everything works fine but when the code execute an Entity Framework Core query, I get this message in the co

Foreign Key word display blank when the app is run

I have built a Book app in ASP.NET Core razor pages CRUD using Entity Framework. However, when I run the app and view it on https://localhost:44370/, the Foreig

EntityFramework is very slow to compare strings because create a nvarchar sqlparameter instead of varchar

I have this sample query: context.BarcodeTipiDoc.AsQueryable().Where(d => d.Barcode.CompareTo(minBarcode) > 0); That query runs very slow because Entit

The corresponding CLR type for entity type 'Employee' is not instantiable

My error: The corresponding CLR type for entity type 'Employee' is not instantiable and there is no derived entity type in the model that corresponds to a conc