Skip to main content

All Questions

0 votes
1 answer
69 views

String interpolation inside a formattable string in C#

I am in the process of replacing Dapper with EF Core in a project. Specifically using the new Database.SqlQuery and Database.ExecuteSql functionality with EF Core. I like how they use ...
Samuel Wahlberg's user avatar
1 vote
1 answer
95 views

How to properly manage and dispose SqlConnection with SqlCredential in EF Core using Dependency Injection?

I am working on an ASP.NET Core project where I am using SqlCredential for database authentication, provided by a SqlCredentialProvider which is designed as a singleton to ensure a single instance ...
Hao Li's user avatar
  • 26
0 votes
0 answers
34 views

Entity Framework Core not recognising mapped user-defined function

I'm using Entity Framework Core with .NET 8 and trying to call a user-defined function from C# code. I'm following the instructions here but have a slightly different use case. Rather than having the ...
amarsha4's user avatar
  • 483
0 votes
0 answers
41 views

Overriding identity tables properties / columns in EF Core 8 has no effect

I'm overriding the IdentityRole / IdentityClaim, etc. However, I've noticed that some of these fields has no effect either in Fluent API or via attributes. Class that overrides IdentityRole<Guid>...
Deukalion's user avatar
  • 2,626
0 votes
0 answers
41 views

Trouble Determining Dependent Side in One-to-One Relationship with Entity Framework Core

I'm currently working on a project using Entity Framework Core in a .NET Core application. I'm having trouble determining the dependent side in a one-to-one relationship between the User and Account ...
changedevelopersoftware's user avatar
1 vote
1 answer
51 views

Group by, count distinct SQL query to IQueryable using Linq

I am trying to translate the following SQL into IQueryable, so I can access the result and filter on different conditions, before the data is retrieved from the database, but I get an error that the ...
Max's user avatar
  • 93
1 vote
1 answer
59 views

Using FromSql or FromSqlInterpolated

According to this documentation (https://www.learnentityframeworkcore.com/raw-sql/from-sql) you should do this: string value = "value"; _dbContext.Set<T>().FromSqlInterpolated($"...
user7849697's user avatar
0 votes
2 answers
82 views

Bulk Insert not respecting Id column with Linq2Db and Entity Framework Core

I am using LINQ to DB with the linq2db.EntityFrameworkCore for bulk-entering of some records. With EF, I just save the records with a 0 in the Id property and they use the sequence I set up on the ...
Killnine's user avatar
  • 5,790
1 vote
0 answers
65 views

Table Design for Calculating Median Over User-Defined Period from Pre-Processed Data

I’m working with a table that contains pre-processed data from several other tables. This data is segmented by a time period (like a day) to speed up queries that could take minutes if I had to ...
Gustavo's user avatar
  • 21
1 vote
0 answers
142 views

Converting SQL ROW_NUMBER to Linq produces wrong translation

I have the following SQL code and I want to convert it to a LINQ query in Entity Framework Core 8. SELECT * FROM( SELECT ROW_NUMBER() OVER (PARTITION BY StaffId,[Location] ORDER BY [Timestamp] ...
derodevil's user avatar
  • 1,007
0 votes
1 answer
407 views

How to use raw SQL query in EF Core get the expected result set in .net core

I am trying to use raw SQL in .NET Core instead of normal EF Core approach. Here is my query and what I am trying to do with it. Entities used here are in a one-to-many relationship as one project can ...
Pratex's user avatar
  • 115
0 votes
0 answers
57 views

LINQ, first record in each group only if condition inside FirstOrDefault is met

I have a main table and a table that contains the translations of this table. Table1 Id Description Table2 Table1_Id Language TranslatedValue To get the grouped values I can left join the first ...
Steven's user avatar
  • 71
1 vote
1 answer
114 views

Deleting an EF Core entity ONLY if it's no longer referenced by parents

Say I have a table called Address which is referenced by Order, Person and Supplier. Let's say I have a method UpdateOrderAddress that changes the order's address: public async Task UpdateOrderAddress(...
Ali Bdeir's user avatar
  • 4,285
3 votes
1 answer
879 views

How to use EF Core and .NET 8 to upsert into a table with many-to-many relationship?

With EF Core and .NET 8, suppose that I used the database scaffolding tool to generate entity classes that look like this: public partial class Person { public int Id { get; set; } public ...
Vivian River's user avatar
  • 32.1k
-1 votes
1 answer
627 views

EF Core 8 does not inject parameters in raw SQL query

I need to build a raw SQL query and I am using the new EF Core 8. But when it executes the query, it seems that the parameters are not getting replaced. private static FormattableString ...
Wasyster's user avatar
  • 2,437

15 30 50 per page
1
2 3 4 5
25