开发者

Is it possible to change the pluralized name of a LINQ table?

For example, my table name is "Diagnosis". When I bring it into my LINQ to SQL model, it tries to figure out how to pluralize it, and it mistakenly assumes the entity name should be "Diagnosi" and the开发者_如何学Python set name should be "Diagnosis", which could be confusing.

When I change the entity name to "Diagnosis" in the properties, it doesn't change the set name, so now they are both "Diagnosis", which is even more confusing.

Ideally, I'd like to have control over the set name and change it to "Diagnoses". I'd settle for LINQ blindly applying its pluralization and coming up with something like "Diagnosises" or something. Any ideas?


As far as I know, you can change the names of tables.

Open up the designer and click the table you want to change. Click again on the table name and it should allow you to rename it. This will not rename the actual database table, to the best of my knowledge, just your entity.

The same information appears in the properties window if you right-click a table and select Properties. You should be able to change the name of the entity which maps to your table there as well.


I don't know of a good way to do this, but here are some ideas:

  • if you don't have to round-trip you model too much, you can override the class names in the generated XML (right click on the DBML, edit in XML editor).
  • you can try to place this one class into a separate model and run SQLMetal manually for it, not from the VS designer (it runs implicitly when you save the model from the designer). I think you can turn off pluralization with a command line option.
  • you can derive from the wrongly named class and give it the correct name, to hide the problem from the developer
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜