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
20
votes
2 answers

GroupBy in EF Core 3.1 / EF Core 5.0 not working, even for the simplest example

I'm updating an EF6.x project to EF Core 3.1. Decided to go back to basics and follow the example of how to set up relationships from scratch again. According to the official Microsoft documentation, EF Core Relationship Examples, I translated the…
Ian Robertson
  • 1,841
  • 1
  • 21
  • 34
15
votes
2 answers

Are EF Core 3.1 ExecuteSqlRaw / ExecuteSqlRawAsync drop-in replacements for ExecuteSqlCommand / ExecuteSqlCommandAsync?

Upon upgrade to EFCore 3.1 deprecated warnings appeared: Warning CS0618 'RelationalDatabaseFacadeExtensions.ExecuteSqlCommandAsync(DatabaseFacade, RawSqlString, params object[])' is obsolete: 'For the async execution of SQL queries using plain…
Caius Jard
  • 47,616
  • 4
  • 34
  • 62
14
votes
1 answer

Problem with EF OrderBy after migration to .net core 3.1

Consider this code: _dbContext.Messages .GroupBy(m => new { MinId = m.SenderId <= m.RecipientId ? m.SenderId : m.RecipientId, MaxId = m.SenderId > m.RecipientId ? m.SenderId : m.RecipientId }) …
12
votes
2 answers

How to use GroupBy in an asynchronous manner in EF Core 3.1?

When I use GroupBy as part of a LINQ query to EFCore, I get the error System.InvalidOperationException: Client-side GroupBy is not supported. This is because EF Core 3.1 attempts to evaluate queries on the server-side as much as possible, as…
Gary
  • 1,275
  • 14
  • 28
11
votes
1 answer

.Net core 3.x Keyless Entity Types avoid table creation

I need to execute a complex sql query in entity framework core 3.1.1, on researching i found out that keyless entity types is the way to go in code first approach. I see lot of documents for dbquery but this is marked as obsolete in .net core…
Richard Vinoth
  • 190
  • 2
  • 10
11
votes
1 answer

How to select top N rows for each group in a Entity Framework GroupBy with EF 3.1

I need to get top 10 rows for each group in a table with entity framework. Based on other solution on SO, I tried 2 things: var sendDocuments = await context.Set .Where(t => partnerIds.Contains(t.SenderId)) .GroupBy(t =>…
Makla
  • 7,975
  • 9
  • 52
  • 118
10
votes
1 answer

Entity Framework creates migration without any updates

At the moment, I'm experiencing an issue where I can create a migration, which has data updates, but the DbContextModelSnapshot has this data. When you look at the updates in the migration, they've already been applied to the DbContextModelSnapshot…
10
votes
3 answers

Entity Framework Core 3.1 with NetTopologySuite.Geometries.Point: SqlException: The supplied value is not a valid instance of data type geography

I have a model that looks like this: public class Facility { [Key] [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int Id { get; set; } public NetTopologySuite.Geometries.Point Location { get; set; } } Test code for…
Ogglas
  • 38,157
  • 20
  • 203
  • 266
9
votes
2 answers

Use both AddDbContextFactory() and AddDbContext() extension methods in the same project

I'm trying to use the new DbContextFactory pattern discussed in the DbContext configuration section of the EF Core docs. I've got the DbContextFactory up and running successfully in my Blazor app, but I want to retain the option to inject instances…
tomRedox
  • 18,963
  • 13
  • 90
  • 126
9
votes
1 answer

Using EfCore lazy-loading proxies with blazor

I am having issues using proxies in EfCore with Blazor. If an object is passed to a sub-component that is accessing its proxied property sometime after the page has been loaded, context may have already been disposed, causing a crash An attempt…
alex-tech
  • 367
  • 1
  • 11
7
votes
1 answer

Issue with scaffolding a MySql database with EF Core - Method not found: Void Microsoft.EntityFrameworkCore.Storage.RelationalTypeMapping

I'm trying to scaffold a MySql Database code first using MySql.Data.EntityFrameworkCore and Microsoft.EntityFrameworkCore on .NET Core 3.1 in Visual Studio 2019. However, I keep getting the following error: Method not found: 'Void…
7
votes
1 answer

EF Core Stored Procedure FromSqlRaw Does Not Give Updated Values

When running a procedure on EF Core 3 using FromSqlRaw that updates values in the table, EF DOES NOT return the updated values when I query the database for those changed values. I have been able to reproduce this behavior. To reproduce create a…
7
votes
1 answer

EF Core 3 DbQuery equivalent functionality

In ef core 2.2 I have used DbQuery to map raw sql results to object as following: public partial class AppDbContext{ public DbQuery SimpleQM {get;set;} } and then var result=_dbContext.SimpleQM.FromSql(sqlString,params); this…
6
votes
7 answers

Error: The name is used by an existing migration

Recently I run add-migration command, and I have some mistakes, so I run remove-migration to undo it. But when I run add-migration again, it said: The name 'blablabla' is used by an existing migration. How to fix this. I already double check…
camahe
  • 276
  • 2
  • 12
6
votes
0 answers

EF Core 3.1 Creating Views in Sqlite in-memory database for testing

I'm using EF Core 3.1 to build out my Database Models for SqlServer. I'm also using EF generated migration files to handle database changes. For testing, I'm spinning up in-memory Sqlite relational database as described in microsoft documentation:…
Steven
  • 540
  • 2
  • 7
  • 17
1
2 3
46 47