Reputation: 3647
I want to add specialized Pluralization rules to my project as I have names in my database like FAS and other things that end with "s" and I want those to be FAS and FASs but the default pluralization wants to make it FASes or something similar which I dont want. I am then trying to use this guide http://blogs.msdn.com/b/efdesign/archive/2008/12/02/pluralization.aspx but I have a hard time figuring out where to put this code? How do I make sure this code is run at startup of my project (I suppose it has to run at startup?)
So where do I put this code?
PluralizationService pluralizationService =
PluralizationService.CreateService(
new CultureInfo("en-US"));
ICustomPluralizationMapping mapping =
pluralizationService as ICustomPluralizationMapping;
if (mapping != null) // it shouldn't be but just checking
{
//Specifying the child pluralizes as children
mapping.Add("FAS", "FASs");
}
Upvotes: 2
Views: 156
Reputation: 4810
When do you need to get the names of the entities pluralized?
I may be way wrong, but it seems to me that you could simply add the tables to the model and just rename them in the designer.
Am I overlooking some information?
Upvotes: 0
Reputation: 17377
The answer is in the tutorial: you have to use it with the schema generator to create the schema using the pluralization service:
EntityModelSchemaGenerator generator =
new EntityModelSchemaGenerator(
storageModel,
"MyNamespace",
"MyContainer",
pluralizationService);
//Generate CSDL and MSL (in memory)
generator.GenerateMetadata();
Upvotes: 1