Howto customize pluralisation for Entity Framework 5

Viewed 536

As my database was designed using german table- and column names, the default pluralisation feature of entity framework doesn't work for me.

I have found a couple of resources where this is discussed, but none of them seem to work.

What i have found: There is the PluralisationService where i can add the mappings:

PluralizationService pluralizer =
      PluralizationService.CreateService(CultureInfo.GetCultureInfo("en-us"));
ICustomPluralizationMapping mapping = ps as ICustomPluralizationMapping;
mapping.AddWord("Tabelle", "Tabellen");

But what's next? I have tried to:

EntityModelSchemaGenerator generator = new EntityModelSchemaGenerator(container);
generator.PluralizationService = pluralizer;
generator.GenerateMetadata();

and put both of them in my POCO T4 Template. But it throwed the following exception:

The EntityContainer 'ContainerName' is not a store EntityContainer. Parameter name: storeEntityContainer
at System.Data.Entity.Design.EntityModelSchemaGenerator.Initialize(...)
at Microsoft.VisualStudio.TextTemplating...GeneratedTextTransformation.TransformText()
3 Answers
Related