Category "entity-framework"

Prevent EF from creating table from subclasses

I have 2 classes; Product and Book. Book is subclass of Product. In my DbContext there is only DbSet of Product. I'm using EF Code-First approach. when EF creat

EF6 Entity framework sometimes slow query on SQL Server

We have started a new project in .NET Core. We are just starting out and we are hitting a Web API endpoint to get some reference data of 8 records. We noticed

MissingMethodException when migrating from Ef 6.2 to 6.4.4

For a .net framework 4.8 project, when I update the EF reference from 6.2 to 6.4.4 the application throw an error System.MissingMethodException: Unable find 'V

EntityFramework 5 Logging in Azure Functions

TLDR; How can we make EF5 logging into its own category instead of the category of the Azure Function? After we upgraded our Azure Functions from .NET core to .

EF core Invalid column name after reverse engineering database using EF Power Tools

I have an API using ASP.NET Core 6 & EF6 and I reverse engineered my database (SQL Server) using the EF Core Powers Tool extension. When I try to insert a P

The corresponding CLR type for entity type cannot be instantiated Table-per-type

Using EFCore 5 I've been trying to follow Microsoft tutorials to create a field in a model class that may reference two other classes. In my case, I have an abs

Relationships in Entity Framework with users from AzureAD

I'm relatively new to Microsoft solutions and I need your guidance. I'm quite certain the answer exist somewhere, but I lack key words for my searches. My stack

COULD NOT LOAD TYPE 'System.Security.Principal.WindowsImpersonationContext' from assembly 'mscorlib'

I'm creating an ASP.NET API Core application, to handle API services, which communicate to an Oracle Database. At runtime, when the process tries to connect to

Entity Framework Core - Relationship between owned child and another chained owned child

I am stuck with Problem, that I am trying to solve the right way. I have multiple one-to-many 'owning' relationships. But I have a duplicate relationship betwee

Errors when "Update model from database" VS2022 and EF5

I am trying to sync EF5 w/ the database by: stackoverflow.com/questions/9708189/… Issue is that after I choose "Updates model from Database" there are er

ASP.NET MVC / Entity Framework - Controller generation is somehow using old properties

After adding and altering columns in the SQL database, I've refreshed the Entity Model (Entity Framework 6) and deleted all controllers and views, to generate t

Linq Nullable object must have a value. errors in .NET 6 and EF Core

I have this code: IQueryable<WinnerClassExtend> dataList = from Class in _context.AllClass join Winner in _context.AllWinners on Class.ClassId equals Win

Object reference not set to an instance of an object on c# EF6

Sometime I get this error message when i run my project in Hosting.There is no problem on the local server. Sometimes this error comes up on the server, sometim

Entity Framework 6 unable to update related models

I have list of models that are attached to a product model, insert is working, but when updated Entity is only updating the product model and ignoring the relat

"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

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

Entity Framework: Getting exception while inserting row in MySQL Table

I recently switched my database from SQL Server to MySQL. I am still using Entity Framework 6 to do CRUD operation in database. When I was using SQL Server as b

Does Entity Framework 6 Have Ability to Add Included Columns When Adding an Index Out of the Box?

I have implemented as suggested here to handle included columns on indexes using EF v3.1.5: https://mindbyte.nl/2017/12/26/Create-indexes-with-included-columns-

How to change table name depends on User in EnityFramework?

I would like to change reference to db table depends on model, which would be send by user. For example: I have 3 types (A,B,C) of devices and 3 tables (tableA,

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