No mapped Doctrine ORM entities according to the current configuration

I've got a dubious issue. I have a set of existing annotated Doctrine entities which have been successfully used in a Symfony2/Doctrine2 project. However, I'm currently isolating some core...

ASP - Core Migrate EF Core SQL DB on Startup

Is it possible to have my ASP Core Web API ensure the DB is migrated to the latest migration using EF Core? I know this can be done through the command line, but I want to do it programatically.

Entity Framework not including columns with default value in insert into query

I have a model that has some columns defined with default values like table.Column<bool>(nullable: false, defaultValueSql: "1") When I save a new entity in the database using...

Entity Framework Core: DbContextOptionsBuilder does not contain a definition for 'usesqlserver' and no extension method 'usesqlserver'

I am new to EF core and I'm trying to get it to work with my ASP.NET Core project. I get the above error in my startup.cs when trying configure the DbContext to use a connection string from...

Unit Testing with Moq sometimes fails on ToListAsync()

I'm fairly new to testing with moq and I'm having a strange issue (at least it seems strange to me), but I'm probably just not setting up the mock object correctly. I have a repository layer that...

Entity Framework Core Database Table Valued Functions Mapping

I use EFCore 2.1 Database First approach. I'm pretty familiar with SQL syntax and prefer build queries myself rather then leave this work on EF. I use Table Valued and Scalar Functions for...

DbContextOptionsBuilder.EnableSensitiveDataLogging Doesn't Do Anything

I'm trying to track down the cause of an Entity Framework InvalidOperationException in an ASP.NET Core project. The exception suggests using DbContextOptionsBuilder.EnableSensitiveDataLogging. In...

ef core, why does it generate this query instead of a simple insert? (save object graph with byte[] inside) and associated performance issue

I'm importing data from a legacy DB to a new project, i'm a bit confused about some of the SQL generated by EF Core (i looked at it in the output view as it was performing very poorly vs what i...

Apply Entity Framework migrations when using ASP.Net Core in a Docker image

I have an ASP.Net Core application which uses Entity Framework with Sqlite. I am building a Docker image to deploy this. The ASP.Net Core application runs fine when debugging with VS Code, but...

How to copy property values to Entity Framework Core object without loosing attached context

We would like to have a method which copies all properties of a given input object to an existing entity framework core object which was loaded from the database and therefore is in attached...

How to avoid DbContext threading issues caused by frequent HttpRequests?

I've taken over a code base from someone else. This is a web application built on Angular 8 (client) and .NET Core 3.0 (server). Brief description of the application: Frequent notifications are...

Entity Framework Core migrations using dockerized postgresql image. No such host is known exception

In my aspnet.core project I would like to use my dockerized postgresql image. Container is running correctly. (I am using Windows but server running on ubuntu18.04 server) CONTAINER ID ...

Your target project 'XXX' doesn't reference EntityFramework. This package is required

Can anyone point me in the direction of where I have gone wrong. I am trying to get migrations to work on EFCore with SQLite (Console App .NET Core 3.1) Running any command such as...

EFCore 2.2 No mapping to a relational type can be found for the CLR type 'Expression[]'

I have a project that used to use DBML as the ORM for getting data out of our database. We are in the process of replacing this DBML with Entity Framework Core 2.2.6 (unfortunately the most recent...

Intercept and alter sql query generated by the Application

I have a situation where a plugin is querying and getting some data, I cannot change the query in plugin as its a DLL. I have checked with the SQL profiler what query it is making and as per our...

Entity Framework Core Error: An error occurred using the connection to database '' on server 'localhost'

I have made an ASP.NET Core 3.1 Web-based application and want to use MySQL as the database. I have been following along with some YouTube tutorials on creating MySQL database with ASP.NET Core...

ASP.NET Core Identity SPA with React

I am confused and a bit lost about using ASP.NET Core Identity with a React SPA. I have read Microsoft documentation about ASP.NET Core Identity several times, mostly focusing on the Identity with...

ASP.NET Core Entity Framework call stored procedure

I am using ASP.NET Core Entity Framework and I would like to call a simple stored procedure. I created the stored procedure in my migrations like this: public partial class spGetAvailableCourses :...

Entity Framework Core: Read and Select Records using NOLOCK

How do I read/select a in Entity Framework Core with NOLOCK? (to avoid locking/blocking/deadlocks in OLTP Database). This is a sample select query. var data= _dbContext.Set<ProductOrder>() ...

EF Core failed to execute database update command : " fail: Microsoft.EntityFrameworkCore.Database.Command[20102] "

Guys I'm trying to run dotnet ef database update command but during the executing of it, it trows me an exception: Failed executing DbCommand (12ms) [Parameters=[], CommandType='Text',...

How to correctly call Postgres Function from entity framework core?

I have a function i need to call from Postgres, This is what i have so far: var s1 = new Npgsql.NpgsqlParameter("_date", NpgsqlDbType.Date) { Direction = System.Data.ParameterDirection.Input, ...

How to return nested tables (one-to-many) in .NET Core WebAPI using Entity Framework Core?

I am new to .NET and having trouble figuring out why Im getting certain results. I found some results on eager vs lazy loading but none of the solutions have worked. I have changed the names of...

Add calculated column from different tables usin ef core 3.1

I want to calculate column value if another column in a related table changes. Product class: public class Product { private int totalQuantity; private bool quantityAlert; [Key,...

Trying to auto-increment counter during edit in ASP.NET Core Entity Framework

I need to auto-increment TimesModified by 1 every time when Edit method is run. When I use the following code, only TimesModified gets incremented but other parameters do not change (even though...

Core Identity Seed User HashPassword failed login

I have a blazor wasm hosted solution .net5 entity framework and identity core. I am attempting to seed an admin user with the following public class ApplicationUserConfiguration :...

How to delete multiple rows in ASP .NET Core from a table in relation one-to-many at once?

I am trying to delete several records from the Locations table at once. However, I get an exception after the second pass of the foreach loop. There is also a RemoveRange method, but it takes...

Entity Framework Core 3.1 is throwing a timeout exception for a query that when executed directly is fast

I have a paged query that throws an time-out exception when executed by EF Core 3.1. Microsoft.Data.SqlClient.SqlException (0x80131904): Execution Timeout Expired. The timeout period elapsed...

Microsoft.EntityFrameworkCore.DbUpdateConcurrencyException: 'Database operation expected to affect 1 row(s) but actually affected 0 row(s)

I have trying to use NUnit for C# unit testing. I am using .NET Core 3.1 and Entity Framework Core. This is my testclass public class IngestServiceTest { private IContext _context; ...

Unable to resolve service for type Microsoft.EntityFrameworkCore.Diagnostics.IDiagnosticsLogger

I am having difficulties to scaffold an existing MySQL database using EF core. I have added the required dependencies as mentioned in the oracle doc: <PackageReference...

A fatal error occurred. The required library libhostfxr.dylib could not be found

I'm working on ASP.NET Project with .NET 5.0. For Database creation, I've run the command dotnet tool install --global dotnet-ef After the installing, when I run this command: dotnet ef I got...