LinqToSql dbml tuning
Remove “DataContext” prefix
When VisualStudio generates firstly dbml, it creates urly-long prefix DataContext, why I dont know! This very annoying to write everywhere, so I decided to show how to delete prefix:
a) click anywhere on the dbml designer surface, and goto Properties tab
b) change Name, its your DataContext, there you can also change Context Namespace
Change names of foreign keys.
Its very usefull to change names of ForeignKeys, especially for case like UserCreated, when User table has dozens of keys, with strange names, even numbers. So:
a) click on the arrows that connecting 2 tables and see Properties
b) change Child or Parent property
AutoGeneratedValue
If you dont need to generate Guids on AppServer, to use it further somehow, you could not put id every time you create object, but use default values. Also default values, I used for DateCreated or such kind of fields with (GetUtcDate()). But if you simply dont fill any data inside, it will put null there. So for that, any column has one of the params - AutoGeneratedValue, put it true, and default will work.
Schema unknown
If you use Visual Studio Dbml creator, and create Tables with DragNDrop, than using local database as source to dbml structure, you also copies schema name you used locally “dbo” most likely. So when you dont know schema of your table on the server, you could clean in “Properties of Column -> Source” by simply delete “dbo.”. This is usefull, if you want to have one dbml for different databases, with different schemas.
