Quantcast
Channel: ADO.NET, Entity Framework, LINQ to SQL, NHibernate
Viewing all articles
Browse latest Browse all 1698

How to use EF Core pluralizer in runtime scaffold

$
0
0

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 ?


Viewing all articles
Browse latest Browse all 1698

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>