0

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.EntityObject
{
    /// <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;
    }
hbrls
  • 2,110
  • 5
  • 32
  • 53

1 Answers1

0

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.

Damb
  • 14,410
  • 6
  • 47
  • 49
  • I pasted some of my code in the original question. I'm now still working on database structures, so the database is still being changed frequently. I want to modify the database and auto reverse engineering the .edmx with VS2008. – hbrls Apr 25 '11 at 02:58
  • If your table in db is name `Questions`, but you want that entity name to be `Question` and older ED doesn't do that automatically, then you have to manually rewrite your names in generated model. I don't see any way around this in your setup. – Damb Apr 25 '11 at 03:01
  • Sorry for not express myself clearly. `Questions` or `Question` doesn't bother me. My question is whether to use `Questions` or `Question` in my partial class so that I can do the works of post form validation. – hbrls Apr 25 '11 at 03:08
  • Ah, sorry. Well.. the answer is to use `Questions` because of that `public partial class Questions` you posted. ;) – Damb Apr 25 '11 at 03:13