Questions tagged [ef-core-3.1]

Use this tag for version specific questions about the 3.1 version of Entity Framework for .NET Core. When using this tag also include the more generic [entity-framework-core] tag where possible.

698 questions
6
votes
1 answer

The LINQ expression could not be translated. Either rewrite the query in a form that can be translated, or switch to client evaluation EF Core 3.1

I'm struggling with this for four days already and no progress at all. Having a query, which worked just fine before updating to EF Core 3.1: var equipments = await this.DbContext.ServContrObjStructEquipment .AsNoTracking() …
Yurii Proniuk
  • 71
  • 1
  • 1
  • 5
6
votes
1 answer

My join .NetCore 3.1 throws an exception about NavigationExpandingExpressionVisitor, what is that?

I have a .NetCore 3.1 project. I know that there are breaking changes from EF Core 2 to 3 but searching for the solution to this is leading me places that make no sense. The following works in .NetCore 2.2. I have a list of user-names that is…
7 Reeds
  • 1,945
  • 2
  • 25
  • 50
6
votes
2 answers

LINQ group by in Entity Framework Core 3.1

I have a database table to connect data between user and clients. db: class UserClientCorporate{ int UserId; User User; int ClientCorporateId; ClientCorporate ClientCorporate; } I want to query to get list of ClientCorporates grouped by…
nightingale2k1
  • 9,113
  • 12
  • 62
  • 90
6
votes
1 answer

Why am I seeing a difference between.Cast() and .Select(a => (int)a)?

I'm trying to work out the difference between the following: someListOfEnums.Cast() and someListOfEnums.Select(a => (int)a)? I have found that the former causes an exception when used in a Where clause in Entity Framework Core 3.1 but the…
SBFrancies
  • 3,211
  • 2
  • 10
  • 33
5
votes
1 answer

EF Core DDD Many-to-many

I'm trying to follow DDD using EF Core and in my model I have the following: private List _personLinks; public IReadOnlyCollection PersonLinks => _personLinks?.ToList().AsReadOnly(); public…
5
votes
1 answer

Table splitting EF Core

I'm trying to use table spliting in EF core. I have an int property that I want to share between two entities stored in the same table. I get an InvalidOperationException saying that the properties sharing the same column have different…
4
votes
3 answers

EF Core saves null value of required property

I have three classes: public class Person { public string Name { get; set; } public Guid Guid { get; set; } } public class Student : Person { public string DOB { get; set; } } public class Teacher : Person { } I want to make string…
Dilshod K
  • 2,106
  • 9
  • 25
4
votes
3 answers

EF Core filter Enums stored as string with LIKE operator

I have a Person model with a Gender enum poperty which is stored as a string in the database. I want to make a query to filter the data by a substring of the gender. For example if the query.SearchLike is "Fe" or "em", I'd like to get back every…
KDani
  • 144
  • 9
4
votes
0 answers

EF Core InMemoryDatabase - How to test with Keyless Entity (mapped to Sql View) - XUnit

Environment: .Net Core 3.1 REST API / EntityFrameworkCore.InMemory 3.1.6 / XUnit 2.4.1 In a Database First Setup I have a model mapped to a Sql View. During Code Generation (with EF Core PowerTools 2.4.51) this entity is marked in DbContext with…
mihai
  • 2,468
  • 3
  • 29
  • 54
4
votes
3 answers

Prevent synchronous API usage with EF Core

How can I prevent synchronous database access with Entity Framework Core? e.g. how can I make sure we are calling ToListAsync() instead of ToList()? I've been trying to get an exception to throw when unit testing a method which calls the synchronous…
Evil Pigeon
  • 1,601
  • 2
  • 19
  • 29
4
votes
1 answer

Memory leak using Autofac with EF Core 3.1 (after migration from 2.2)

I'm experiencing a memory leak when using an EF Core 3.1.5 (after migration from 2.2) with Autofac 5.2.0. My scenario is that on the home page I load some list of products and each reload of a page increase the amount of memory used by 5-10mb,…
MNie
  • 1,187
  • 1
  • 14
  • 30
4
votes
1 answer

EF Core - Populate an UnMapped column from raw SQL?

I have a query where I'm doing a Count on a specific join/column - If I run this code with the "Clicks" [NotMapped] attribute removed, all the values populate properly - but then inserts fail since "Clicks" is not a valid column name. When I mark…
4
votes
0 answers

EF Core cascade delete nullable foreign keys

We would like to change the deletebehavior from the nullable foreignkeys to cascade. So if we remove Item, we also would like to remove SubItemA and SubItemB if it is not null. We already tried several things with fluentapi, but we cannot seem to…
Emmie
  • 664
  • 4
  • 17
4
votes
1 answer

How to debug Expression.Lambda? (Difference in Expressions tree evaluation between .net core 2.1 and .net core 3.1)

I've created a small program that shows some differences between .net core 2.1 and 3.1: using System; using System.Linq.Expressions; using Microsoft.EntityFrameworkCore.Query; public class Program { public static void Main() { var…
theCuriousOne
  • 576
  • 7
  • 15
4
votes
0 answers

Is it posible to do a select for postgresql using UNACCENT extension IN EF CORE 3.1 with npgsql?

I have read about this for in Npgsql and Entity Framework Query PostgreSQL with Npgsql and Entity Framework using unaccent, BUT Entity Framework CORE. Is it posible to do a select for postgresql using unaccent extension USING EF CORE 3.1? How to…
netcorefan
  • 41
  • 1
1
2
3
46 47