2

My SQL tables names are all plural - Events, Teams, Campuses, etc... When I drag the tables in to the dbml, it creates an entity called "Campuse" which of course is incorrect. I manually rename that to Campus in the properties page, but it doesnt seem to update all of the auto generated code correctly. For example, the .designer.cs file has the following code:

    public System.Data.Linq.Table<Campus> Campus

when it should be

    public System.Data.Linq.Table<Campus> Campuses

Similar problems with association names.

I could probably go through all of that generated code, and try to rename everything manually, but that's a pain. Is there a better way?

Gert Arnold
  • 105,341
  • 31
  • 202
  • 291
PeteShack
  • 707
  • 1
  • 8
  • 20

1 Answers1

8

You can turn off automatic pluralization of LINQ-to-SQL entities, and that should correct your problem. Unfortunately, LINQ-to-SQL (and the Entity Framework) are designed to work with the much more prevalent practice of naming tables in singular form. The code generator will try to figure out the singular form of what it sees as a plural word, but it's not particularly adept at this task.

Community
  • 1
  • 1
Adam Robinson
  • 182,639
  • 35
  • 285
  • 343
  • Thanks. Didnt realize the prevalent practice was to use singular table names. I guess that makes sense if you just think of the tables as the structure and not the actual set of records. Using singular names helped, but it still had problem with "campus" since it ended in "s". Just had to manually edit one line. – PeteShack Nov 25 '09 at 14:51
  • @PeteShack I also wasn't aware that was the prevalent practice. I'm a contractor and I've never worked for any organisation where table names used the singular form. Ever! That ranges across SQL, MySQL and Oracle. – Jacques Feb 07 '18 at 07:21