Reputation: 11069
I'm trying to use the interface IPluralizationService
to customize the pluralization of my entities without success!
Necessary that all entities are pluralized using the Inflector library.
class Config : DbConfiguration
{
public Config()
{
SetPluralizationService(new CustomPluralization());
}
}
class CustomPluralization : IPluralizationService
{
public string Pluralize(string word)
{
return word.Pluralize();
}
public string Singularize(string word)
{
return word.Singularize();
}
}
In my context;
modelBuilder.Configurations.Add<Config>(.. ?? ..)
Upvotes: 3
Views: 1149
Reputation: 3809
According to msdn's article Code-Based Configuration (EF6 onwards) section Using DbConfiguration, it is sufficient to simply place your DbConfiguration
class in the same assembly as your DbContext
class.
Nevertheless you can specify it manually, as explained in the article by using either the config file or an annotation in your DbContext
.
<entityFramework codeConfigurationType="MyNamespace.MyDbConfiguration, MyAssembly">
<!-- Your EF config -->
</entityFramework>
[DbConfigurationType("MyNamespace.MyDbConfiguration, MyAssembly")]
public class MyContextContext : DbContext
{
}
Or
[DbConfigurationType(typeof(MyDbConfiguration))]
public class MyContextContext : DbContext
{
}
These examples are directly from the article I linked
Upvotes: 1