[英]How fix the name for class not auto singularize
Using EF to create the classes I choose the singularize option. 使用EF创建类,我选择单数化选项。 Some of the classes were singularize but other doesn't.
一些类是单数的,而其他则不是。
This work ok: 这项工作还可以:
products -> product
presentations -> presentation
But this two wasn't: 但是这两个不是:
price_sources -x-> price_source
user_types -x-> user_type
Manual method: 手动方式:
Right click on empty space in the edmx window and select Model Browser
. 右键单击edmx窗口中的空白区域,然后选择“
Model Browser
。
In the Model Browser
of the edmx file you can rename the generated class names for the Tables under the DBModel --> Entity Types
by right clicking on the class names and selecting Rename
. 在edmx文件的
Model Browser
中,可以通过右键单击类名称并选择“ Rename
来Rename
DBModel --> Entity Types
下表的生成类名称。 This will not break the code on subsequent updating of the models from database. 在随后从数据库更新模型时,这不会破坏代码。 But if you delete and re-add the same table you will have to repeat the above steps.
但是,如果删除并重新添加同一张表,则必须重复上述步骤。
I do these steps to avoid the CA warning for using underscores in class / property names 我执行这些步骤以避免在类/属性名称中使用下划线的CA警告
The answer is that tables with underscores cannot be automatically pluaralized/singularized in EM. 答案是带有下划线的表不能在EM中自动复数/单数化。
For more details, see: https://blogs.msdn.microsoft.com/efdesign/2008/12/01/pluralization/ 有关更多详细信息,请参阅: https : //blogs.msdn.microsoft.com/efdesign/2008/12/01/pluralization/
You will have to configure the table name explicitly. 您将必须显式配置表名称。
You can also use a custom pluralization service to write your own rules. 您还可以使用自定义的多元化服务编写自己的规则。
Details here: Entity Framework EDMX - Entity Pluralization Fix 此处的详细信息: 实体框架EDMX-实体复数修复
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.