Skip to main content

Questions tagged [ef-core-7.0]

Use this tag for version specific questions about the 7.0 version of Entity Framework for .NET Core (including release candidates). When using this tag, please also include the more generic [entity-framework-core] tag. Also, please note that other minor versions than "0" may be more applicable.

ef-core-7.0
Filter by
Sorted by
Tagged with
47 votes
6 answers
46k views

Entity Framework Core 7 connection certificate trust exception

I recently upgraded to Entity Framework Core 7 in development and I'm getting an exception: A connection was successfully established with the server, but then an error occurred during the login ...
user3802434's user avatar
25 votes
6 answers
28k views

dotnet ef update database : A connection was successfully established with the server, but then an error occurred during the login process

When I run dotnet ef update database I get this error: A connection was successfully established with the server, but then an error occurred during the login process. (provider: SSL Provider, error: 0 ...
Amirabbas Motamedi's user avatar
15 votes
2 answers
6k views

EF 7 - new ExecuteDelete and ExecuteUpdate methods not working on an in-memory database

I'm using the new EF 7 ExecuteDelete and ExecuteUpdate features and they are great. But when I try to write unit test for the functions that use them, these tests crash. I'm using EF 7.0.1 on .NET ...
Ivo Oostwegel's user avatar
14 votes
3 answers
9k views

'Fragment' does not have an implementation exception when trying to add migration with EF Core 7

When I'm trying to add a migration using EF Core (7.0.0-rc.1.22426.7) I'm greeted with the following error in the console: System.TypeLoadException: Method 'Fragment' in type 'Microsoft....
Stijn VH's user avatar
  • 141
13 votes
2 answers
19k views

Error in 'SqlQuery' method is not natively supported by your database provider

In function execution calls of dbContext.Database.SqlQuery<T> the following exception: 'The element type 'MyEntity' used in 'SqlQuery' method is not natively supported by your database provider....
Thiago Guislotti's user avatar
13 votes
1 answer
1k views

.NET 7 JsonPolymorphic and EF Core 7 Json Column

I switched form .NET 6 to .NET 7 to make use of the polymorphic serialization with System.Text.Json. In WebApi, serializing and deserializing works like a charm using these types: [JsonDerivedType(...
martinoss's user avatar
  • 5,448
8 votes
0 answers
700 views

EF core 7 is not allowing to map multiple properties of an entity with single database column whereas it was working in earlier EF Core versions

Earlier I had mapped multiple properties with single db column as below and it was working. Now after upgrading to EF Core 7, it's showing error: both properties mapped to column 'variableName' in '...
Sid's user avatar
  • 81
6 votes
2 answers
1k views

Project EF Core 7 result to named tuple

I'm using EF Core 7. I want to perform server evaluation and project to a named tuple. I tried: var products = await _context.Products.Select(x => (x.Id, x.Name)).ToListAsync(); Which gives: An ...
lonix's user avatar
  • 17.7k
5 votes
1 answer
1k views

EF Core 7 no definition for ExecuteUpdateAsync

I have the following query in my project which is using Microsoft.EntityFrameworkCore 7.0.2: await _context.Actions .Where(a => a.DateCreated < DateTime.Today && a.ActionType == (int)...
Pete's user avatar
  • 58.1k
5 votes
1 answer
942 views

Can I force Entity Framework Core 7 to not make ICollections read-only? [duplicate]

Entity Framework Core 7 introduced a breaking change (although it is not listed in the breaking changes for EF Core 7): when defining model classes with scaffolding (Scaffold-DbContext), EF Core 7 now ...
user736570's user avatar
5 votes
1 answer
3k views

not found: 'Void CoreTypeMappingParameters..ctor

I updated my project from ef 6 to 7 and got this error not found: 'Void CoreTypeMappingParameters..ctor(System.Type, Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter, Microsoft....
mahdi's user avatar
  • 258
4 votes
2 answers
12k views

Getting Database ConnectionString from appsettings.{Environement}.json in .Net Core 7 inside Program.cs?

In older versions of ASP.Net core you had the startup.cs file where you would do a lot of the work including reading and setting the application environment then based on that you could read ...
Matthew Verstraete's user avatar
4 votes
1 answer
250 views

Migrations creates extra keys and indexes

I've been working recently on setting up a code first database via EF Core 7.0.4 but I'm encountering a strange behavior when I run the migrations -> extra alternate keys and indexes are being ...
cdrrr's user avatar
  • 1,114
4 votes
1 answer
410 views

EF Core QueryExpressionInterceptor for DayOfWeek

We had an existing application using ASP.NET MVC and EF6. We migrated to ASP.NET Core and EF Core 7. As title suggests, we are having trouble with existing queries where DayOfWeek is used. DayOfWeek ...
Dharmesh Tailor's user avatar
4 votes
4 answers
763 views

EF Core 7.x with JSON column fails on 'add migration'

I have a Student model class with a property that I want to save as JSON in the database. I am using .NET Core 7.x with EF Core 7.x and MySQL. My Student model is simple: public class Student : ...
Yaniv Amrami's user avatar
4 votes
2 answers
415 views

EF Core, efficient way of adding a multitude of large entities to the many-to-many relationship of another entity?

lets say I have two Models, Tags and Posts, and the Tag Model is very large (lots of columns). A Tag can have Multiple posts, and a Post can have multiple Tags. The only way I know how to set ...
Daniel Goldberg's user avatar
4 votes
0 answers
139 views

Using FromSqlRaw with TPT inheritance in EF Core 7

We are trying to use the FromSql method in a DbSet of a class that implements TPT inheritance, and we are getting this error: Using 'FromSql' on DbSet of 'CuSimple' is not supported since 'CuSimple' ...
Mendi's user avatar
  • 71
4 votes
0 answers
617 views

Entity Framework JSON Column Store data As UniCode in SQL Server

In a .NET 7 Web API project, I try to use EF7 JSON column to store translations of the entity. These are my entities: public class Card { public int Id { get; set; } public string Name { get; ...
Ahmed Hesham's user avatar
3 votes
2 answers
2k views

How to set null in update with ef core 7 ExecuteUpdateAsync SetProperty

I have this method: public async Task<int> RemoveClassify(RemoveClassifyVm vm) { return await _db.UserAccesses .Where(UserAccess => vm.userAccessIds.Any(userAccessId => ...
Mohammad Komaei's user avatar
3 votes
2 answers
3k views

EF Core 7 can't deserialize dynamic-members in JSON column

I am trying to map my Name column to a dynamic object. This is how the raw JSON data looks (note that this is SQL-morphed from our old relational data and I am not able to generate or interact with ...
Starlotus Sora's user avatar
3 votes
3 answers
2k views

How to define where clause for ExecuteDelete/ExecuteUpdate methods of EF core 7 with generic type properties?

I have a generic repository with the following definition : public class DataRepository<TEntity, TEntityIdType> : IDataRepository<TEntity, TEntityIdType>where TEntity : class , IEntity<...
goodstas's user avatar
3 votes
3 answers
2k views

EF Core 7 Linq with a 'Contains" generates an SQL with an extra 'or is not null'

I recently updated EF Core 6 to 7, and now a query has become a lot slower than before without any changes. It looks like EF Core translated the LINQ query to a different SQL query. Versions: .NET: 7 ...
J Flex's user avatar
  • 464
3 votes
1 answer
551 views

Why might an EF Core 7 query be slow only sometimes?

I'm using EF Core 7 as the ORM in a Blazor Server application that I am writing. Most of my queries are small and don't cause any problems. However, I have one large query that will generally execute ...
waffleShirt's user avatar
3 votes
0 answers
153 views

EF Core explicit loading query with owned type collection causes cartesian explosion error

I have an EF Core entity with a collection of owned entities (Customer.Contacts) and a collection of regular entities (Customer.OrderedProducts). When I load data using "explicit loading", I ...
lonix's user avatar
  • 17.7k
3 votes
1 answer
586 views

How to filter, order and query LTree in EF Core

As already described here I'm struggling with LTree and the right way to query. I'm using an object, containing LTree as a column on one of my tables. This is how the object looks like: using ...
Joshit's user avatar
  • 1,315
3 votes
0 answers
209 views

EF Core : Inject custom SqlExpressionFactory

Our DB contains data that can be translated. To store the data and the translation, it has two table : One to contains data in the default language (ex : Product) One to contains translations that is ...
vernou's user avatar
  • 7,414
3 votes
0 answers
629 views

EF Core 7 makes required column nullable if property name matches table name

I have the code shown below which has one Entity Framework class, with a [Required] string field. When I run the code, it prints the following: CREATE TABLE [MyStuff] ( [MyTableKey] bigint NOT ...
Doug's user avatar
  • 483
3 votes
0 answers
491 views

Use JsonDocument with SQL Server in EF Core 7. The LINQ expression cannot be translated

I am using EF Core 7. I have a requirement to save dynamic json at run time. I am using the System.Text.Json.JsonDocument class in the class, as shown below. public class SomeEntity : IDisposable { ...
Ghyath Serhal's user avatar
3 votes
0 answers
195 views

EFCore 7 TPC Strategy with abstract User class

I'm working on a university management web app that I'm trying to make for a school project. Currently I have 3 classes in my project as follows: public abstract class User : IdentityUser<string>...
lightofpast's user avatar
3 votes
0 answers
119 views

EF Core 7.0 Migration Ignores DeleteBehavior.NoAction

I have an EF Core model with a root entity type that has multiple one-to-many relationships with other entity types. Some of these child types also relate to each other, so I understand that I need to ...
Tim Coulter's user avatar
  • 8,885
2 votes
1 answer
6k views

linq expression for ExecuteUpdateAsync

I have found ExecuteDeleteAsync and ExecuteUpdateAsync in EF Core 7 with great enthusiasm. They help to make my code much simpler and faster. There is no need to use self-made procedures for batch ...
Stanislav Gordenko's user avatar
2 votes
2 answers
5k views

Querying a custom type with Database.SqlQuery<T> in EF Core 7.0

The recently released Entity Framework Core 7.0 offers a new DatabaseFacade.SqlQuery<T> function, which allows to run custom SQL queries directly on the underlying database context. For custom ...
janw's user avatar
  • 9,396
2 votes
1 answer
2k views

Entity Framework Core 7 apply custom ValueConverter to Inserts and Updates

I am struggling to understand how to apply a custom ValueConverter to all the properties of all the models before every insert and update. According to this resource it can be done: https://learn....
user avatar
2 votes
2 answers
1k views

'IServiceCollection' does not contain a definition for 'AddIdentity'

Before I tested this line on a web application in core 5. services.AddIdentity<Operator, IdentityRole>().AddEntityFrameworkStores<StorageContext>().AddDefaultTokenProviders(); This works ...
kmboon's user avatar
  • 21
2 votes
1 answer
392 views

ExecuteUpdateAsync: Could not be translated

I'm facing an issue trying to perform a bulk update through EFCore 7 ExecuteUpdateAsync() method. The error message says: .ExecuteUpdate(calls => calls.SetProperty( propertyExpression: x => x....
Gonzo345's user avatar
  • 1,273
2 votes
1 answer
292 views

C# Entity Framework Core - LINQ check the presence of one array in another

If you try to find entities that contain genres from the query (they may also contain other genres that are not in the query), you will get an error. I tried many options but ended up with 3 requests. ...
omlain's user avatar
  • 25
2 votes
1 answer
430 views

Interceptor for ExecuteUpdate crashes when trying to SetPropertyCall with string variable

I'm trying to set the base model that contains edit date and editUserId for all my models through a interceptor when calling ExecuteUpdate. But when I try to set the user id the program crashes with ...
Kyeman's user avatar
  • 57
2 votes
1 answer
1k views

Why is AsSplitQuery doing separate roundtrip to DB for each query?

I have finally been able to upgrade a very old codebase from EF6 to EF Core 7 and I'm playing with some "new" features. I have been super hyped about Split query option for eager loading but ...
Ladislav Mrnka's user avatar
2 votes
2 answers
1k views

How to get foreign key linked values while using generic repository and unit of work patterns with Entity Framework Core

I am new to Entity Framework Core 7 and ASP.NET Core 7 MVC. I am learning the concepts using the Northwind database. I am using a generic repository and UnitOfWork pattern on top of EF Core for data ...
user466663's user avatar
2 votes
1 answer
1k views

EF Core 7.0 Error: "Add the entity seed to 'X' and specify the foreign key values" when already specified

I am having trouble seeding unidirectional relationships. The seeding looks as follows: User 1-->* Post I'm receive this error on configuration Unhandled exception. System....
Lukas Knudsen's user avatar
2 votes
0 answers
145 views

Query selects all columns even though only one column is selected

I have encountered an issue while working with Entity Framework Core 7 where the generated SQL query appears to select all columns from the table, even though I am selecting only one column in my LINQ ...
PriceOne's user avatar
2 votes
0 answers
151 views

EF Core .Include() select latest item works wrong

My code: var file = await this._dataContext.Files .AsNoTracking() .Where(x => x.Id == id) .Include(x => x.FileVersions.OrderByDescending(y => y....
A. Gladkiy's user avatar
  • 3,322
2 votes
0 answers
389 views

EF Core 7 Json column projections - LINQKit - LINQ expression could not be translated

I have an issue with mapping an EF Core 7 Json column into an class. I am presented with the following exception. System.InvalidOperationException: The LINQ expression 'JsonQueryExpression(p....
Jack Smith's user avatar
2 votes
0 answers
1k views

How to mock ExecuteUpdateAsync

How to mock EF 7.0 ExecuteUpdate method. Like SaveChangesAsync() how to mock set up the ExecuteUpdateAsync. I am using NUnit for unit test case ExecuteUpdateAsync(a => a.SetProperty(u => u....
coder11 b's user avatar
  • 139
2 votes
0 answers
255 views

Visual Studio 2022 removes part of connection string on publish - .NET 7

My appsetting.json file contains : "ConnectionStrings": { "Server=localhost;Database=db;Trusted_Connection=True;encrypt=false;MultipleActiveResultSets=true" } After migration ...
mordechai's user avatar
  • 839
2 votes
0 answers
360 views

How to get list of JSON navigations of a EF Core 7 entity?

I have some models that are created in a DBContext. Some of them may have some navigation properties. I get IEntityType of those models using this method: var entityType = context.Model.FindEntityType(...
HamidEbr's user avatar
  • 405
2 votes
0 answers
547 views

Using reverse engeneering with Scaffold-DBContext, makes virtual collections read-only

Using EF Core 7, after scaffolding, the generated code looks like this: public partial class Category { public Guid CategoryId { get; set; } public Guid Title { get; set; } public virtual ...
Arash Ghasemi Rad's user avatar
2 votes
1 answer
1k views

emptyprojectionmember' was not present in the dictionary

I have recently upgraded my application running Entity Framework Core 2.1.1 to Entity Framework Core 7.0.11. The following part of code (C#) ran fine with the older version: var items = _dbContext....
Angelo's user avatar
  • 89
1 vote
2 answers
334 views

Efficient way to delete/update entities in EF Core 7 by a list of conditions

I need to delete/update a given number of rows of a table. In one I solved it like this: await context.MyItems .Where(x => itemsIds.Contains(x.Id)) .ExecuteUpdateAsync(f => f....
Art's user avatar
  • 207
1 vote
1 answer
136 views

Why is .Where acting as IEnumerable insteading of IQueryable?

I implemented an extension/helper called WhereIf of Type IQueryable, as you may have guessed by the name of it, it applies the filtering only if a pre-condition is met and is chained in ...
Yuri Soares's user avatar

1
2 3 4 5