views:

243

answers:

1

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?

+2  A: 

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.

Adam Robinson
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