.NET

@aspnet

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

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

Representing available string values for parameters as list in Swagger ASP.NET Core

Valid values as list in Swagger UI in ASP.NET Core
 
 
0
Swagger is a great way do describe your RESTful API. In ASP.NET it is pretty easy to wire up your OpenAPI documentation with your service facade with Swashbuckle NuGet package. In .NET 5, WebApi project template comes with already built in support for OpenAPI via Swashbuckle package and you can get it already setup in your pipeline and dependency injection with an easy tick in new WebApi project in Visual Studio. ...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. Typical dependency injection lifetime of DbContext is scoped, which means you can execute one command at the time as the DbContext is instantiated per HTTP request in ASP.NET Core application. ...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. Let try to see what is the obstacle of doing tis with EF Core in a sample project which will access two databases in order to execute query and return records from the database...read more

Building and using advanced .NET Core CLI global tools

Handling commands, arguments and options in .NET CLI global tool application
 
0
Once .NET Core 2.1 SDK introduced support for global tools I wrote a brief article on how to create a simple global CLI tool in .NET Core Building advanced .NET Core Global Tool using CommandLineUtils package. While this is fair enough informations to kick-start you project and create a simple global tool to use from the command line, I found out there is more to it in order to have the tool built, published, distributed and used especially when you are dealing with real-life applications that need to have a CLI as a part of the solution. ...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

Using Polly for retrial policies with Autofac

Confguring and using Polly with with pretty much anything
0
Some time ago I wrote an article which explains how to Increase service resilience using Polly and retry pattern in ASP.NET Core. This is a great way how to easily implement retrials when using .NET Core dependency injection, but in case of using Autofac with .NET Framework 4.x you do not have many out of the box solutions. However, Polly as a library is not specifically built for .NET Core and using it with other dependecy injection packages such as Autofac is fairly easy...read more

JavaScript

read more

SQL/T-SQL

read more

Umbraco CMS

read more

PowerShell

read more