Questions tagged [entity-framework-core]
For questions about Entity Framework Core (EF Core) for .NET Core. Please also add a version-specific [ef-core-xx] tag, when applicable. Note that Entity Framework for .NET Framework is an older, different product that fits the [entity-framework] tag.
entity-framework-core
22,748
questions
-1
votes
1
answer
56
views
Equals method never called by LINQ expression [duplicate]
My data class:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using static iText.StyledXmlParser.Jsoup.Select.Evaluator;
...
0
votes
0
answers
56
views
Entity Framework: could not create socket for "db_connection": listen unix /tmp/cloudsql-proxy-tmp/db_connection/.s.PGSQL.5432: bind: invalid argument
I'm using Google Cloud Run to host a .Net Core 8 application using the Google Cloud Functions Framework. THe entity framework version is 8.0.7. The PostgreSQL database is hosted on Google Cloud SQL. ...
0
votes
1
answer
55
views
Issue with LINQ Query in Async Method: 'The LINQ expression could not be translated'
I have an asynchronous method in C# that retrieves a list of users with various nested includes and filters. The method works fine when I don't pass the arbsResponse parameter, but I encounter an ...
-1
votes
0
answers
64
views
Performance degradation of linq query in C# after .NET Core upgrade to 8 [duplicate]
I have the simple linq query in my .NET Core C# app. We have upgraded from .NET Core 3.1 to .NET 8.
My query is as follows:
Decimal[] cks = mem.Select(a => Convert.ToDecimal(a.KEKE_CK)).ToArray();
...
1
vote
2
answers
42
views
Unable to create an object of type 'IdentityDataContext'
I'm encountering an issue while trying to update my database using Entity Framework Core in my .NET project. When I run the command:
dotnet ef database update --context IdentityDataContext
I receive ...
0
votes
1
answer
49
views
dotNET minimal API getting 404 not found on a secure endpoint
I am trying to implement a rest api using the dotNET framework. I am experiencing a problem with the "/secure" endpoint, getting 404 as a response message whether I login or not.
If I don't ...
0
votes
0
answers
46
views
.Net Core 8 Entity Framework (MySQL) DROP PROCEDURE IF EXISTS `MYSQL_BEFORE_DROP_PRIMARY_KEY` Error
I'm created a migration to add a few tables and update one table (add one column). The database is MySQL 8.0.31 and the EF provider is Oracle's MySql.EntityFrameworkCore
The migration was completed ...
0
votes
1
answer
53
views
System.InvalidCastException: Can't cast database type timestamp without time zone to DateOnly
I get this error message when using EF Core to query data:
System.InvalidCastException: Can't cast database type timestamp without time zone to DateOnly
This is a sample code that causes an error ...
-1
votes
0
answers
51
views
Why where clause ignores data comparison? [closed]
I have such code:
var utcNow = DateTime.UtcNow;
Expression<Func<MyEntity, bool>> condition = entity => entity.StartedAt <= utcNow && entity.EndedAt >= utcNow;
var query = ...
0
votes
1
answer
38
views
Unable to perform migrations in .NET Core
The error which I am facing:
PM> update-database
Build started...
Build succeeded.
An error occurred while accessing the Microsoft.Extensions.Hosting services. Continuing without the application ...
0
votes
0
answers
31
views
Storing tree structures where a node can be in multiple trees
I am trying to find a way to build a model in Entity Framework to represent Courses and Lessons, where each course can have multiple Courses and lessons within it. However i also want to make it so ...
0
votes
0
answers
53
views
Adding complex objects in .NET Core
These are my entities:
public class Order
{
[Key]
public long OrderId { get; set; }
public string CustomerId { get; set; }
[ForeignKey("CustomerID")]
[Required]
...
0
votes
0
answers
33
views
EF Core : how to make sure we get up to date data from a DbSet
I'm pretty new to EF Core and I'm a facing an issue where I get some entities that do not seem to exist in my database anymore.
Here is how I proceed:
var myEntity = _context.MyDbSet.Where(m => m....
0
votes
1
answer
34
views
EF Core customize scaffolding without deriving from internal classes
Entity Framework Core Customize Scaffolding describes a process for customizing the entities created when scaffolding an existing database using Entity Framework Core. This we've done successfully up ...
0
votes
1
answer
78
views
ModelBuilder Entity in ASP.NET Core MVC
In ASP.NET Core 6, I need to rename the database model of ASP.NET Core Identity. I do not use APIs, but just ASP.NET Core 6 MVC.
This my code:
protected override void OnModelCreating(ModelBuilder ...