为什么实体框架复数化并使实体类名称大写? [英] Why does entity framework pluralize and capitalize entity class names?

查看:173
本文介绍了为什么实体框架复数化并使实体类名称大写?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么实体框架将所有类名复数化,默认大写第一个字母?这样做有什么好处?可能是一个愚蠢的问题,但只是出于好奇?

Why does entity framework pluralize all the class names and capitalize the first letters by default? What are the advantages of doing this ? Probably a stupid question...but just out of curiosity?

推荐答案

资本化约定 .NET开发类库的设计指南,它指出所有类名应该在Pascal的情况下,它定义为:

In the Capitalization Conventions section of the .NET Design Guidelines for Developing Class Libraries, it states that all class names should be in Pascal case, which it defines as:


标识符
中的第一个字母和每个
的第一个字母的后续连接词是
大写,可以使用Pascal case
用于三个或更多
个字符的标识符,例如:

"The first letter in the identifier and the first letter of each subsequent concatenated word are capitalized. You can use Pascal case for identifiers of three or more characters. For example:

BackColor

对于多元化,当您使用实体框架模型设计器的默认设置时,我发现你会相反。它会将多个表名转换成其单数等价物。例如,使用Northwind数据库并使用默认设置,我发现设计人员会将Products表更改为名为 Product 和Categories表的类,名为分类。这是有道理的,因为对象的单个实例将是 Product 而不是产品

As for pluralization, I find you get the opposite when you use the default settings for the Entity Framework model designer. It will convert plural Table names to their singular equivalent. For instance, using the Northwind database and using the default settings I find that the designer will change the Products table to a class called Product and Categories table to a class called Category. This makes sense since a single instance of an object would be a Product and not a Products.

如果你得到相反的效果,那么我很困惑。不过,请查看这篇文章 - 实体框架4.0:多元化 by Dan Rigsby,这可能解释了发生了什么。

If you are getting the opposite effect then I'm puzzled. However, check out this article - Entity Framework 4.0: Pluralization by Dan Rigsby, which perhaps explains what is happening.

这篇关于为什么实体框架复数化并使实体类名称大写?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆