1

When I generate LINQ-to-SQL classes for a table named ApplicationMenus it doesn't create a singular class for it so that the statement:

ApplicationMenu applicationMenu = new ApplicationMenu();

gives an error.

If I change the name of the table to one of these:

Menus
ApplicationMenuItems

then it correctly generates the singular class.

Why does LINQ-to-SQL have a problem with "ApplicationMenus" and what other names will cause a problem as well?

alt text

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Edward Tanguay
  • 189,012
  • 314
  • 712
  • 1,047
  • Related but different: http://stackoverflow.com/questions/1794872/linq-to-sql-with-table-name-ending-in-es-creates-wrong-entity-class-name – Marc Gravell Nov 26 '09 at 18:54
  • I can understand it might have a problem with difficult words such as "Campuses" etc. (although a simple little mapping table would take care of that), but the odd thing is that it works with "Menus" but not "ApplicationMenus". – Edward Tanguay Nov 26 '09 at 19:01
  • 2
    Are you not able to change the generated class name in the properties of the linq-to-sql file? – Graham Clark Nov 26 '09 at 19:02

1 Answers1

0

You could use reflector to find out, or you could ask yourself why you have pluralized table names ;-)

Klaus Byskov Pedersen
  • 117,245
  • 29
  • 183
  • 222
  • 2
    Perhaps because he has a "table of application menus"? instead of "table of application menu"? It's like "public List Employee { get; set; }" in C#, it just gives you the wrong impression. Is it 1 employee or a list of employees, or what? Of course, if the "application menu" is a list of items, so that the table actually contains items instead of multiple menus, then the naming is just odd. – Lasse V. Karlsen Nov 30 '09 at 20:22