toddams/RazorLight

Entity Framework Core and RazorLight : "An error occurred while accessing the Microsoft.Extensions.Hosting service"

Opened this issue · 0 comments

Describe the bug
When you add RazorLight to your Console App that use EF Core, operation like add-migration or update-database raise this error/warning : "An error occurred while accessing the Microsoft.Extensions.Hosting services"

To Reproduce

  • Using VS2022, create a new Console App for .NET 6.0
  • Add the following nuget packages :
    • "Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.10"
    • "Microsoft.EntityFrameworkCore.Tools" Version="7.0.10"
    • "RazorLight" Version="2.3.1"
  • In the package Manager Console, launch the following command : "add-migration CreateDB"
  • Result is : "Build started...
    Build succeeded.
    Hello, World!
    An error occurred while accessing the Microsoft.Extensions.Hosting services. Continuing without the application service provider. Error: The entry point exited without ever building an IHost.
    To undo this action, use Remove-Migration.
    "

Expected behavior
Same result but without the message "An error occurred while accessing the Microsoft.Extensions.Hosting services..."

Information (please complete the following information):
Note that I have on another project the following message : An error occurred while accessing the Microsoft.Extensions.Hosting services. Continuing without the application service provider. Error: An exception has been raised that is likely due to a transient failure. Consider enabling transient error resiliency by adding 'EnableRetryOnFailure' to the 'UseSqlServer' call.