Skip to content

Scaffolding fails with a service registration error. #30

@MartinKleiner

Description

@MartinKleiner

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>();

        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions