10 .NET Library Tools that You Must Have

In this article, I will recommend 10 .NET libraries tools that can help you in build your .NET applications. Hope you enjoy this article.

1. MediatR

The mediator pattern is simply implemented in-process by MediatR. It aids programmers in writing tidy, decoupled, and extensible code. Dependency injection is used to configure Mediator, which comes preconfigured with support for Autofac,.NET Core, and other technologies. The best place to start is with Github’s documentation.

I enjoy using MediatR to create straightforward command-query requests that make use of the IRequest interface. IRequest messages are handled by a single handler. IRequest types like “GetUserQuery” and “UpdateCartCommand” are examples that you might see in a typical web application. The query model and query handler are kept together in one class in the example below by using an internal nested class.

Additionally, Mediatr supports notification messages with multiple handlers via INotification. Requests and notifications function similarly, but notifications don’t return values. They are excellent for making a “extension point” in your application that you might need to expand upon visible.

2. Serilog

Serilog offers structured logging with output that can be directed almost anywhere. Your log statements and objects are recorded in structured logs as json. Compared to standard text logs, they provide a lot more context for what is occurring in your application and can be queried and analyzed in greater detail with the right tools.

One of the best things about Serilog is that practically every service you can imagine has sinks created by the community, which write logs to a provider. A complete list can be found on the provided sinks Github page. I suggest you look at the following two:

  • Seq – self hosted structured log viewer
  • Sentry – exception reporting service that plugs in automatically to error log events

3. Hangfire

For.NET Core and Framework applications, Hangfire is a simple way to run background tasks that can be fired once and forgotten about. I adore how simple it is to start using it because it doesn’t require a separate service since the jobs can run within your app’s main process.

Hangfire features a fantastic dashboard that is already built in, support for dependency injection, and storage options for SQL server, PostgreSQL, Redis, and more.

4. LazyCache

LazyCache is a developer-friendly, simple-to-use wrapper for in-memory caching in.NET Core.

When using LazyCache, you can request an item from the cache while also providing the function to add the item to the cache if it is missing. This technique is known as the “GetOrAdd” pattern.

Since LazyCache is simple to extend, the transition from a straightforward in-memory cache to something distributed should be fairly simple.

5. Dapper

Entity Framework’s SQL data access can occasionally be excessive or simply too slow. Dapper is the way to go if you want to execute raw SQL and still get nice object mapping.

Dapper uses the database connection you already have and adds extension methods to execute raw SQL and translate it into C# classes.

6. MiniProfiler

A straightforward performance profiler for.NET Core and framework (as well as Ruby, Go, and Node) web applications is called MiniProfiler. It automatically connects to the crucial components of your application, primarily database access. Then MiniProfiler will display a fantastic little timing result right in your app. Running it while developing is a great way to catch errant LINQ queries.

MiniProfiler has a ton of options and excellent setup documentation.

7. FluentMigrator

Both FluentMigrator and DbUp will work if you’re looking for an alternative to running EntityFramework code first migrations.

DbUp functions best if you enjoy simple scripts and raw SQL. Simple add SQL files as embedded resources to a console application that you have already created. a small amount of program code.It’s simple to integrate cs into a devops pipeline and have it run your migration scripts sequentially.

Similar ideas are used by FluentMigrator, but it takes a more coding-based approach. For each migration, you create a small class rather than adding raw scripts. This method allows for more thorough up/down migration scenarios and gives you more flexibility when creating migrations (while saving you from having to remember the create foreign key sql syntax).

8. CsvHelper

My go-to package for reading and writing csv files is CsvHelper. Because of the library’s flexibility, you can either use the low level row and column methods directly or create your own custom mapping classes and rules for your C# classes.

Similar options exist for exporting csv files, including using classes and mapping or direct column writes.

9. Humanizer

Dates, numbers, enums, and other data are transformed into readable strings for humans using humanizer. It works with many languages and supports a wide variety of data types.

10. LinqKit

For using Linq to query Entity Framework, there is a set of extensions called LINQKit. You can create LINQ queries and conditions as predicates using LINQKit.

The PredicateBuilder is the LINQKit feature I use the most to streamline complex queries (imagine grids with filters).


That’s .NET library that you can use for development. Do you have other suggestion? Please comment below. Thank you

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *