What is the plurality naming "problem" in context of Entity Framework?
What do the people mean when talking of the plurality naming "problem" in context of Entity Framework?开发者_开发问答
From http://www.cnblogs.com/zjz008/archive/2010/06/03/1750442.html (re: Entity Framework 4.0 Features)...
Plurality Naming
One of the big complaints in the first version of the Entity Framework was how naming conventions were applied to EDM objects such as entities and navigation properties when using the model wizards.
The first version of the Entity Framework gave the Entity Name and the Entity Set Name the same name. There was no attempt to singularize or pluralize names when generating a model from a database. The problem is that this caused some confusion when referencing the database table or EntityType in code. For example, if your database has a table called Employees, then you will also get an EntityType called Employees as well. This causes confusion about whether you are referencing the table or the EntityType, such as in the code fragment below.
Customers customer = new Customers();
Luckily, this issue has been addressed. The model wizards, both the Entity Data Model and Update Model Wizards, now provide the option of using singular or plural forms of names for entities, entity sets, and navigation properties.
The goal of this change was to make the application code much easier to read and avoid a lot of the confusion between object names.
It revolves around the fact that database objects named in certain ways will lead to either incorrect pluralization or singularization. A good example of this is illustrated by this Microsoft Connect issue.
In this example, database objects end in "Status" are incorrectly singularized as "Statu", instead of being treated as a singularization that would be pluralized as "Statuses".
It is annoying, but I wouldn't consider it to be widespread enough to deter a person from using EF.
精彩评论