MiniProfiler for .NET
repository·main·Indexed 25 days ago
https://github.com/miniprofiler/dotnetA performance profiling tool for .NET applications, including ASP.NET, ASP.NET Core, and ASP.NET MVC, designed to help developers identify bottlenecks in code and database queries. It provides integration for Entity Framework Core, Entity Framework 6, and various database providers such as SQL Server, PostgreSQL, MySQL, SQLite, MongoDB, and Redis. The tool uses a hierarchical JSON structure to represent profiling data, including server-side timing trees and browser-side client timings.
What's inside MiniProfiler for .NET
- MiniProfiler for .NET is a profiling tool designed for ASP.NET, ASP.NET Core, ASP.NET MVC, and general .NET applications. It allows developers to monitor and profile application performance. The project is part of the .NET Foundation.
Install MiniProfiler for .NET Core Console Applications
mainTo use MiniProfiler in a .NET Core Console application, you must install the
MiniProfiler.AspNetCoreNuGet package, as there is no dedicated package for standalone Console applications. This package includes all necessary dependencies.Install-Package MiniProfiler.AspNetCore -IncludePrereleaseConfigure persistent storage for MiniProfiler results
mainBy default, MiniProfiler stores results in memory. To persist results in a database, install the appropriate provider package and assign it to
MiniProfiler.Settings.Storage.Example: Using SQL Server
- Install the
MiniProfiler.Providers.SqlServerNuGet package. - Configure the storage in your application startup code:
MiniProfiler.Settings.Storage = new SqlServerStorage(ConnectionString);- Install the
Profile Entity Framework Core with MiniProfiler
mainTo profile Entity Framework Core queries using MiniProfiler, you must install the
MiniProfiler.EntityFrameworkCoreNuGet package and register it in your application's service configuration. This allows MiniProfiler to intercept and record EF Core database commands.public void ConfigureServices(IServiceCollection services) { services.AddMiniProfiler() .AddEntityFramework(); }Install MiniProfiler for ASP.NET Core
mainTo use MiniProfiler in an ASP.NET Core application, install the
MiniProfiler.AspNetCore.MvcNuGet package. This package includes all necessary dependencies.You can install it via the NuGet UI or using the Package Manager Console.
Install-Package MiniProfiler.AspNetCore.Mvc -IncludePrereleaseVerify minimum requirements for MiniProfiler v4
mainTo use MiniProfiler v4, your project must meet the following minimum requirements:
- Framework: .NET 4.6.1 or above, or .NET Standard 1.5 or above.
- Note: .NET 4.6.1+ is strictly required to support the
asyncfeatures implemented in version 4.
If your environment is older than .NET 4.6.1, you must use MiniProfiler v3.x.
Upgrade RenderIncludes from V3 to V4
mainIn MiniProfiler V4,
RenderIncludes()has changed from a static method to an instance method.To fix this, call it on the
MiniProfiler.Currentinstance instead of the static class.Install MiniProfiler.Mvc5 for ASP.NET
mainTo use MiniProfiler in an ASP.NET MVC 5 application, install the
MiniProfiler.Mvc5NuGet package. This package includes all necessary dependencies.You can install it via the NuGet UI or using the Package Manager Console:
Install-Package MiniProfiler.Mvc5 -IncludePrereleaseInstall the MiniProfiler.EF6 NuGet package
mainInstall theMiniProfiler.EF6NuGet package to provide the integration between MiniProfiler and Entity Framework 6.Install MiniProfiler for .NET Console Applications
mainTo use MiniProfiler in a .NET Console application, install the
MiniProfilerNuGet package. This package includes all necessary dependencies.You can install it via the NuGet UI or using the Package Manager Console.
Install-Package MiniProfiler -IncludePrereleaseSelect the correct MiniProfiler NuGet package for your framework
mainMiniProfiler is modular. Choose the package that matches your application type:
ASP.NET Core (.NET Standard 2.0+)
- Core functionality:
MiniProfiler.AspNetCore - MVC Integration:
MiniProfiler.AspNetCore.Mvc
ASP.NET Full Framework
- Core functionality:
MiniProfiler - MVC 5 Integration:
MiniProfiler.Mvc5
- Core functionality:
Initialize MiniProfiler for Entity Framework 6
mainTo enable profiling, you must call
MiniProfilerEF6.Initialize()in your application startup logic. This must be called before any Entity Framework operations occur in your application. Ensure you include theStackExchange.Profiling.EntityFramework6namespace.using StackExchange.Profiling.EntityFramework6; // ... protected void Application_Start() { MiniProfilerEF6.Initialize(); }