Disabling automatic pluralization in Linq to SQL C

2020-07-07 05:18发布

问题:

I have a single table name with an irregular plural (the plural is the same as the singular). Is there any way to disable the automatic pluralization (Account = DB.Accounts) for that single table while retaining the feature for the others?

回答1:

You need to disable the Pluralize Table Names for the LINQ to SQL designer.

To do this navigate to Tools -> Options -> Database Tools -> O/R Designer and change the Pluralization of names to false.

Then you will need to recompile your project and it should address the naming

Linq to SQL: How do I stop the auto generated object name from being renamed?



回答2:

If you're really only worried about a single class, I would let the Framework pluralize the name and then simply manually remove the pluralization for the one class you're worried about.



回答3:

I think you can´t do this using pure Linq2SQL.

On Entity Frameowrk + T4 template for generate Linq 2 SQL entities you can customize a T4 template for take control of pluralization, implementing your own rules exceptions.