Quantcast
Channel: Entity Framework
Viewing all articles
Browse latest Browse all 10318

Edited Unassigned: DELETE:Custom PluralizationServices is getting hit twice, breaking my table names [1657]

$
0
0
__
Oh NEVERMIND, my extra call to base. Pluralize was triggering it. I've come up with a workaround.__


I've declared my pluralization service in DbConfiguration.

During code first db initialization, it is iterating through the service twice. The first time it gets the table names fixed up properly. But then it comes through again with the table names and modifies them, wrecking my customizations.

Here is what I'm doing.

I have a variable that represents an EnglishPlrualizationService. I use that to pluralize if non of my special rules are hit.

public string Pluralize(string word)
{


if (word.EndsWith("ou"))
{
return string.Format("{0}z", word);
}
if (word.EndsWith("us"))
{

return string.Format("{0}ii", word.Remove(word.Length-2));
}
if (word.StartsWith("French") && word.EndsWith("al"))
{
return string.Format("{0}aux", word.Remove(word.Length - 2));
}
return baseService.Pluralize(word);

}

So for an entity named "Journal", the first pass sees the "al" and returns "Journaux".

On the second pass, "Journaux" is run through the base servcie and my table is named "journauxes".

How can I avoid this. Is there a reason it goes through twice? Is it a bug?

Viewing all articles
Browse latest Browse all 10318

Trending Articles



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