MongoFramework icon indicating copy to clipboard operation
MongoFramework copied to clipboard

Add MiniProfiler Tutorial

Open Turnerj opened this issue 4 years ago • 3 comments

Following on from #183 , this would be a tutorial about using MiniProfiler. The scope is much smaller as the intention is that someone knows how to use the basics of MongoFramework.

The tutorial should explain what MiniProfiler is, why it is useful and then show how to add it to the project. Finally, it should show an example of a successful profile of a query.

Turnerj avatar Oct 14 '20 06:10 Turnerj

Have you an example of how to setup the MiniProfilerDiagnosticListener? I have miniProfiler running already.

grounzero avatar Aug 16 '21 22:08 grounzero

This is what I do in my own application for configuring it:

var mainContextConnectionString = Configuration.GetConnectionString("MainContext");
var mainContextMongoUri = new MongoDB.Driver.MongoUrl(mainContextConnectionString);
services.AddTransient<IMongoDbConnection>(s =>
{
    var connection = MongoDbConnection.FromUrl(mainContextMongoUri);
    connection.DiagnosticListener = new MiniProfilerDiagnosticListener();
    return connection;
});

I really should make a fluent API for it as it would be a lot more concise.

Turnerj avatar Aug 17 '21 01:08 Turnerj

This is what I do in my own application for configuring it:

var mainContextConnectionString = Configuration.GetConnectionString("MainContext");
var mainContextMongoUri = new MongoDB.Driver.MongoUrl(mainContextConnectionString);
services.AddTransient<IMongoDbConnection>(s =>
{
    var connection = MongoDbConnection.FromUrl(mainContextMongoUri);
    connection.DiagnosticListener = new MiniProfilerDiagnosticListener();
    return connection;
});

I really should make a fluent API for it as it would be a lot more concise.

Thanks

grounzero avatar Aug 17 '21 01:08 grounzero