Tagged articles
Image from Pexels

Tagged articles - EF Core

Found 12 articles tagged with EF Core

Controlling the flow of migrations in EF Core
Altering EF Core migrations execution order
0
EF Core has migrations as a way of restoring the database structure inherited from Entity Framework and for the most of the cases all you have to do to setup your database structure changes when deploying your new application version is to call the Migrate method from your DbContext.Database property. It is not a perfect solution but as I mention, it works great for majority of the cases and takes of the complexity of sorting out order for execution of pending changes so you can focus on business logic of your application. ...read more
Using interceptors with dependency injection in Entity Framework Core
EF Core interceptors via dependency injection in ASP.NET 5
0
I while ago I wrote an article on how to Access multiple databases from the same DbContext in EF Core which relies on interceptors to mutate the SQL query diring execution. This code works just fine and it updates the command prior to it's execution, but it lacks in option to inject registered services to it's constructor as i used new keyword to initialize class instances. Adding interceptor without dependency injection ...read more
Implementing soft delete in EF Core using triggers
Entity soft delete implementation in EF Core
0
Implementation approach for soft delete is more-less straight forward thing. Instead of deleting data record, you introduce a flag which will mark the record as deleted and you can simply filter out on it and not show the data with the flag set. This way you do not loose data, but you restrict the end user to see it. This way of "deleting" data records, or better said marking them as deleted applies for certain types of applications, but sometime this requirement may come later as a new feature while the actual delete is in place...read more
Mocking view mapped DbSets with XUnit in EF Core
Writing unit tests for view bounded entities in EF Core
 
0
Using in-memory DbContext is a great way to mock your actual DbContext in unit tests. You basically initialize the instance of your DbContext and seed some random data before you assert the result of your repository method...read more
Setting up SQL Server IDistributedCache with migration in ASP.NET Core
Embedding SQL Server caching in a project with EFCore migration
0
Caching data using Microsoft SQL Server may not be the most popular way of caching data because of the performance comparing to caching data to Redis, but it is maybe the most convenient way to keep your state of the application outside the process itself. Beside, if you are already using SQL Server database, you can just move the caching infrastructure to a separate schema inside the same database and keep using it until requirements are met for cache storage of better performance (like Redis for example). This makes infrastructure not so complex and less dependent, again until the requirements for something faster are met. ...read more
Running multiple queries at the same time in EF Core
Overcoming the limitation of EF Core query execution
 
0
Since the time of ADO in .NET one of the limitations was that one connection can execute single command at the time. Same limitation Entity Framework inherited and you can execute single command at the time per instance of your DbContext...read more
Accessing multiple databases from the same DbContext in EF Core
Multiple database access from the same DbContext in Entity Framework Core 5
 
0
It is not uncommon to have a requirement to access tables or views in different databases in the same query. In order to be able to do your joins on tables or views in different databases you need to do it in the same connection instance which is bound to DbContext, therefore this access as to be accomplished from the same DbContext instance...read more
Seeding data in EF Core using SQL scripts
Another way of seeding data in EF Core
0
Not so while ago I wrote an article on Seeding data with Entity Framework Core using migrations. This approach relies on EF Core migrations to ensure seeding of specific data is done only once using __EFMigrationsHistory table to track structural migrations as well as data seeding migrations. In large number of cases this approach works just fine and you do not need to do any adjustments or add any additional tables, just use migrations mechanism out of the box...read more
Seeding data with Entity Framework Core using migrations
Using EF Core migrations to seed the data
0
As much as it is important for testing the functionality of the application, data seeding can also be used to pre-load some values like lookups not only to development and test environment but also to populate these values in production as well. Seeding of data can be done in several ways and in this article I will go through two ways of seeding data. Both of them have their pros and cons and it is up to you to pick the way you want to have your data pre-seeded in your application database. ...read more
Tracking data changes with Entity Framework Core
History/Audit of data changes using Entity Framework Core
0
Tracing data changes can be beneficial in narrowing down the issue that may occur in production. If you are using Entity Framework Core you have several ways to store actions performed against your data...read more
Logging EF Core actions to a file using Serilog
Log Entity Framework Core using Serilog in .NET Core application
0
Logging is an essential part of the application. It gives you insights which allows you to see your application behavior or even user behaviour and actions taken by them in the application.Serilog is most probably the most popular library for logging in .NET Core applications...read more
Seeding data in Entity Framework Core from Visual Studio
Insert sample data from Visual Studio IDE with EF core
 
0
Unlike Entity Framework 6, EF Core and whole .NET Core relies on dependency injection. For example, configuration is expected to be injected from the calling assembly instead of being available at any time...read more

.NET

read more

JavaScript

read more

SQL/T-SQL

read more

Umbraco CMS

read more