Tried to use runtime scaffold in EF Core with NpgSql EF Provider
Created scaffolder as described in https://github.com/jdtcn/RuntimeEfCore :
using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Design; using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Scaffolding; using Microsoft.EntityFrameworkCore.Scaffolding.Internal; using Microsoft.EntityFrameworkCore.Storage; using Microsoft.Extensions.DependencyInjection; using Npgsql.EntityFrameworkCore.PostgreSQL.Diagnostics.Internal; using Npgsql.EntityFrameworkCore.PostgreSQL.Scaffolding.Internal; using Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal; using Humanizer; ... static IReverseEngineerScaffolder CreatePostgreScaffolder() { return new ServiceCollection() .AddEntityFrameworkNpgsql() .AddLogging() .AddEntityFrameworkDesignTimeServices() .AddSingleton<LoggingDefinitions, NpgsqlLoggingDefinitions>() .AddSingleton<IRelationalTypeMappingSource, NpgsqlTypeMappingSource>() .AddSingleton<IAnnotationCodeGenerator, AnnotationCodeGenerator>() .AddSingleton<IDatabaseModelFactory, NpgsqlDatabaseModelFactory>() .AddSingleton<IProviderConfigurationCodeGenerator, NpgsqlCodeGenerator>() .AddSingleton<IScaffoldingModelFactory, RelationalScaffoldingModelFactory>() // Type or namespace Bricelam not found // .AddSingleton<IPluralizer, Bricelam.EntityFrameworkCore.Design.Pluralizer>() .AddSingleton<IPluralizer, Humanizer.Pluralizer>() .BuildServiceProvider() .GetRequiredService(); } This causes two compile errors: > CS0234 The type or namespace name 'Pluralizer' does not exist in the> namespace 'Humanizer' (are you missing an assembly reference?)> > CS0411 The type arguments for method> 'ServiceProviderServiceExtensions.GetRequiredService<T>(IServiceProvider)'> cannot be inferred from the usage. Try specifying the type arguments> explicitly.
.NET 5 EF Core uses Humanizer for pluralization so it should exist.
How to scaffold in runtime from MVC Core application ?