Entity Framework do not Pluralize my SQLServer database
I'm using .NET Framework 3.5. So I think the EF is also 3.5. I saw something here: EF3.5 don't Singularize or Pluralize names.
Unfortunately in the current version of the Entity Framework, which ships in .NET 3.5 SP1, we don't make any attempt to Singularize or Pluralize names when reverse engineering a model from the database.
And in my MVC2 project, I want to code a partial class For Orders for form validation purposes. Which is correct? Can you suggest some sample files.
public partial class Order { ... }
public partial class Orders { ... }
The code from my .cs after .edmx:
public partial class Questions : global::System.Data.Objects.DataClasses.Enti开发者_开发百科tyObject
{
/// <summary>
/// Create a new Questions object.
/// </summary>
/// <param name="questionnaireGUID">Initial value of QuestionnaireGUID.</param>
public static Questions CreateQuestions(string questionnaireGUID)
{
Questions questions = new Questions();
questions.QuestionnaireGUID = questionnaireGUID;
return questions;
}
You can pluralize enities names manually in your .edmx model.
Partial class depends on name of entity class, that is generated.You can again check entity model (this time its .cs class) and there you will find if you got Order
or Orders
generated.
Edit:
You have found public partial class Questions
in your edmx, so if you want to create validation class to this, you must again use public partial class Questions
. If you would use singular form, the classes wouldn't be connected, becuase at this level, they are just classes and the compiler probably wouldn't guess, that he should connect Question with Question*s*. Those class names are just strings without any semantics inside them.
精彩评论