实体框架EDMX - 实体多元化修复 [英] Entity Framework EDMX - Entity Pluralization Fix
问题描述
我们已经在PluralizationService中发现了某些单词的错误,例如,它认为校园是复数形式,并且它被Campu单数化。
We have found some bugs for certain words with the PluralizationService, for example it thinks "Campus" is plural, and it singularizes it by "Campu".
我们已经弄清楚如何使用ICustomPluralizationMapping界面向服务添加自定义映射,问题是,我们如何告诉EntityModelCodeGenerator使用我们的自定义服务而不是基础?
Anyhow, we have figured out how to add custom mappings to the service using the ICustomPluralizationMapping interface, the problem is, how do we tell the EntityModelCodeGenerator to use our custom service instead of the base one?
我们正在使用EF 4.2数据库,首先使用自定义的T4模板。
We are using EF 4.2 database first with custom T4 templates.
推荐答案
也许这篇文章是有帮助的: http://blogs.msdn.com/b/efdesign/archive /2008/12/02/pluralization.aspx
Maybe this article is helpful: http://blogs.msdn.com/b/efdesign/archive/2008/12/02/pluralization.aspx
Update1:
您需要添加此代码(示例):
Update1: You would need to add this code (sample):
//Create an EDM from SSDL generator
EntityModelSchemaGenerator generator =
new EntityModelSchemaGenerator(
storageModel,
"MyNamespace",
"MyContainer",
pluralizationService);
//Generate CSDL and MSL (in memory)
generator.GenerateMetadata();
到T4模板。为了做到这一点,您必须将模板添加到您的项目中:右键单击模型设计器中的可用空间,然后选择添加代码生成项。然后选择所需的模板,您将能够自定义此模板。
to the T4 template. In order to do that, you have to add the template to your project: Right click on a free space in the model designer and chose "Add code generation item". Then select the desired template and you will be able to customize this template.
参考: http://onlinecoder.blogspot.de/2011/03/customize-entity-framework-code.html
和 http://www.matthidinger.com/archive/2010/02/09/customizing-the-entity-framework-t4-template-suppressing-code-analysis.aspx
Update2:文本转换&寻找实体多元(收藏)
这篇关于实体框架EDMX - 实体多元化修复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!