EntityFrameworkCore.OpenEdge icon indicating copy to clipboard operation
EntityFrameworkCore.OpenEdge copied to clipboard

Scaffolding fails with a service registration error.

Open MartinKleiner opened this issue 2 months ago • 0 comments

Scaffolding fails with a service registration error.

Unable to resolve service for type 'Microsoft.EntityFrameworkCore.Diagnostics.IDiagnosticsLogger1[Microsoft.EntityFrameworkCore.DbLoggerCategory+Scaffolding]' while attempting to activate 'EntityFrameworkCore.OpenEdge.Scaffolding.Internal.OpenEdgeDatabaseModelFactory

To make scaffolding work, I had to change Design/Internal/OpenEdgeDesignTimeServices.cs to register the EF Core design-time services and the provider services like this:

using EntityFrameworkCore.OpenEdge.Extensions;
using EntityFrameworkCore.OpenEdge.Scaffolding.Internal;
using EntityFrameworkCore.OpenEdge.Storage.Internal.Mapping;
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.EntityFrameworkCore.Design.Internal;
using Microsoft.EntityFrameworkCore.Scaffolding;
using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.Extensions.DependencyInjection;

namespace EntityFrameworkCore.OpenEdge.Design.Internal
{
    public class OpenEdgeDesignTimeServices : IDesignTimeServices
    {
        public void ConfigureDesignTimeServices(IServiceCollection services)
        {
            services.AddEntityFrameworkOpenEdge();

            new EntityFrameworkRelationalDesignServicesBuilder(services)
                .TryAddCoreServices();

            services.AddSingleton<IDatabaseModelFactory, OpenEdgeDatabaseModelFactory>();
            services.AddSingleton<IProviderConfigurationCodeGenerator, OpenEdgeCodeGenerator>();
            services.AddSingleton<IAnnotationCodeGenerator, OpenEdgeAnnotationCodeGenerator>();

        }
    }
}

MartinKleiner avatar Nov 28 '25 11:11 MartinKleiner