diff --git a/Fritz.InstantAPIs.sln b/Fritz.InstantAPIs.sln index 6c40561..a069bb2 100644 --- a/Fritz.InstantAPIs.sln +++ b/Fritz.InstantAPIs.sln @@ -17,6 +17,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution .editorconfig = .editorconfig CODE-OF-CONDUCT.md = CODE-OF-CONDUCT.md CONTRIBUTING.md = CONTRIBUTING.md + RELEASE_NOTES.txt = RELEASE_NOTES.txt EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Test", "Test\Test.csproj", "{CD123B01-1B52-4E80-84F7-4D10E01EE10F}" diff --git a/Fritz.InstantAPIs/WebApplicationExtensions.cs b/Fritz.InstantAPIs/WebApplicationExtensions.cs index 8f0a7a2..9302903 100644 --- a/Fritz.InstantAPIs/WebApplicationExtensions.cs +++ b/Fritz.InstantAPIs/WebApplicationExtensions.cs @@ -2,6 +2,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Extensions.Options; using System.Reflection; @@ -36,8 +37,12 @@ public static IEndpointRouteBuilder MapInstantAPIs(this IEndpointRouteBuilder private static void MapInstantAPIsUsingReflection(IEndpointRouteBuilder app, IEnumerable requestedTables) where D : DbContext { - var loggerFactory = app.ServiceProvider.GetRequiredService(); - var logger = loggerFactory.CreateLogger(LOGGER_CATEGORY_NAME); + ILogger logger = NullLogger.Instance; + if (app.ServiceProvider != null) + { + var loggerFactory = app.ServiceProvider.GetRequiredService(); + logger = loggerFactory.CreateLogger(LOGGER_CATEGORY_NAME); + } var allMethods = typeof(MapApiExtensions).GetMethods(BindingFlags.NonPublic | BindingFlags.Static).Where(m => m.Name.StartsWith("Map")).ToArray(); var initialize = typeof(MapApiExtensions).GetMethod("Initialize", BindingFlags.NonPublic | BindingFlags.Static);