I've tried to start the AspNetCore.HealthCheckier.UI with the .Net Core 6 like so:
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddRazorPages();
builder.Services.AddHealthChecksUI().AddInMemoryStorage();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (builder.Environment.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapHealthChecksUI();
endpoints.MapRazorPages();
});
app.Run();
But I get some incomprehensible error when I reach app.run:
System.InvalidOperationException: Sequence contains more than one matching element
at System.Linq.ThrowHelper.ThrowMoreThanOneMatchException()
at System.Linq.Enumerable.TryGetSingle[TSource](IEnumerable1 source, Func
2 predicate, Boolean& found)
at System.Linq.Enumerable.Single[TSource](IEnumerable1 source, Func
2 predicate)
at Microsoft.EntityFrameworkCore.Query.QueryableMethods..cctor()
Any idea? I cannot run exact same syntax in .Net Core 5, but similar code does work in .Net Core 5.