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
8,789
questions with no upvoted or accepted answers
17
votes
1
answer
5k
views
Entity Framework Core 2.0 deleting record instead of updating it
I think this could be a bug but thought I might be missing something that could explain the behavior. Any help would be appreciated.
### Technical details
EF Core version: Microsoft....
15
votes
0
answers
3k
views
Table Partitions with Entity Framework Core
I have a large database that will use partitioned column-store tables in a redesign. Is it possible to specify the partition in the generated sql with Entity Framework Core 2.2?
This is for an Azure ...
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(...
12
votes
0
answers
416
views
C# .NET 6 - simple SQL query to read one single (large) record takes forever when run is K8S pod, instantaneous when run in IIS
I have a simple table in SQL Server:
CREATE TABLE [dbo].[MyTable]
(
[Ticket] [uniqueidentifier] NOT NULL,
[UserID] [int] NOT NULL,
[Progress] [int] NOT NULL,
[Created] [datetime2](7) ...
12
votes
0
answers
9k
views
EF Core: Use multiple database schemas in DbContext object?
We have a database where the tables are organized in multiple schemas like Common.User and Product.Order. There are also tables with the same name in different schemas.
Is it somehow possible to use ...
11
votes
1
answer
1k
views
Using resource-based authorization on a list in ASP.NET Core/Entity Framework Core 3.1
Premise
The documented method to apply resource-based authorization in ASP.Net Core is to register an AuthorizationHandler, define each OperationAuthorizationRequirement, then check access to ...
11
votes
0
answers
1k
views
Entity Framework Linq query is client-evaluated when using custom type with ValueConverter
I'm working with Microsoft's Entity Framework Core and tried to utilize ValueConverters to allow for custom types in my database model entities. The point is to have my own type which I can customize ...
11
votes
4
answers
14k
views
Find a generic DbSet in a DbContext dynamically
I know this question has already been asked but I couldn't find an answer that satisfied me. What I am trying to do is to retrieve a particular DbSet<T> based on its type's name.
I have the ...
10
votes
1
answer
2k
views
Applying EF Core migrations per tenant schema
I'm working with .NET Core 3.1 and EntityFramework Core 3.1.3.
I'm trying to implement tenant data separation using DB schemas. I've read this. I'm aware it's a little bit outdated, so I've adjusted.
...
10
votes
3
answers
2k
views
Mapping object as identity column in entity framework core
It is possible map object as identity column with value generated typeof int ?
I tried like this but this no help. i've got error
Identity value generation cannot be used for the property 'Id' on ...
10
votes
0
answers
1k
views
F# and migrations using Entity Framework Core
Hi i have a question,
Using entity framework core in c# I am able to do migration of db if it does not exits on startup and it looks fairly easy (using this documentation https://learn.microsoft.com/...
10
votes
1
answer
10k
views
Configuring DbContext Constructor
I'm trying to use EF Core tools to manage an SqlServer database I'm designing in a C# class library. It's in a class library because I need to use the database schema in both an MVC6 website and some ...
9
votes
0
answers
2k
views
Store Enums as Strings in EF Core 6
While looking for a solution to store all our enums as strings in the database, i came up with the following code.
protected override void ConfigureConventions(ModelConfigurationBuilder builder)
{
...
9
votes
0
answers
2k
views
EF Core migration bloat - is it necessary? Can the designer files be deleted?
I have a project that has been a work in progress for several years. It is continually growing and changing. And our data layer project is now 10 times the size of any other project, and takes about 5 ...
9
votes
0
answers
2k
views
Foreign key to table in different dbcontext with Entity Framework Core
How can I add a foreign key reference to a table in a different DbContext with Entity Framework Core?
class DonationContext : DbContext
{
public decimal Amount { get; set; }
public string ...