It’s often useful to have our entities inherit from a base class. This is easily done using EF Core Power … Continue reading Make entities inherit from a base class in Entity Framework Core DB First
Category: Entity Framework Blog
Below there’s 70+ Entity Framework blog posts on a large variety of Entity Framework topics including:
- new features coming in upcoming versions of EF.
- performance optimisation topics such as using split queries, and how to select only specific columns.
- architecture topics like should we use the repository pattern over Entity Framework and how can we have private constructors and setters when using DB first.
- how-tos, troubleshooting, useful links, miscellaneous etc.
Excluding tables in Entity Framework Core Scaffold-DbContext command
In Entity Framework Core DB First if you don’t want models created for certain tables you need to explicitly list … Continue reading Excluding tables in Entity Framework Core Scaffold-DbContext command
Setting Global Query Filters on multiple entities dynamically in Entity Framework Core
Since Entity Framework Core 2 we can use Global Query Filters to add where clauses to any queries EF generates … Continue reading Setting Global Query Filters on multiple entities dynamically in Entity Framework Core
Using Entity Framework Core Interceptors to log SQL queries
Since version 3 Entity Framework Core has supported Interceptors. The interception API allows developers to easily intercept and examine and … Continue reading Using Entity Framework Core Interceptors to log SQL queries
Run Scaffold DBContext without overwriting custom code in Entity Framework core.
I prefer to use DB first approach with Entity framework as many do. In this scenario when the underlying DB … Continue reading Run Scaffold DBContext without overwriting custom code in Entity Framework core.
Generating sequential GUIDs which sort correctly in SQL Server in .net
Using a non sequential GUID in either a clustered or non clustered index is not ideal from a performance point … Continue reading Generating sequential GUIDs which sort correctly in SQL Server in .net
Viewing SQL generated by Entity Framework when querying or calling SaveChanges()
When using Entity Framework, in an effort to track down bugs or performance problems, it’s very handy to see what … Continue reading Viewing SQL generated by Entity Framework when querying or calling SaveChanges()
Validation failed for one or more entities. See ‘EntityValidationErrors’ property for more details
You may see this exception when doing a DbContext.SaveChanges() call. You then may go drilling into the exception details to … Continue reading Validation failed for one or more entities. See ‘EntityValidationErrors’ property for more details
Passing userId to SQL Server delete trigger from entity framework
If you’re in an enterprise environment some form of auditing is likely to be required so you can track who … Continue reading Passing userId to SQL Server delete trigger from entity framework
Improving performance of read only selects in entity framework by turning off tracking with AsNoTracking method
We had a new contractor start the other day in work and he brought to my attention the ability to … Continue reading Improving performance of read only selects in entity framework by turning off tracking with AsNoTracking method
Using Optimistic concurrency with Entity Framework over SQL Server
If you want to have a client-wins or last in wins approach to concurrency management you don’t have to do anything, … Continue reading Using Optimistic concurrency with Entity Framework over SQL Server