Reputation: 20946
Im using vs2008 and Im also using the autogenerated object model / entity classes from linq to sql (.dbml).
Is it possible / recommended to change the autogenerated .cs file. Eg change the behaviour of Equals (in the partical class Courses)?
I do know that Equals should be reflexive, symmetric, transitive, consistent and "Equals(null)== false "
Upvotes: 3
Views: 850
Reputation: 36310
You can also add a common base class for your entities where you implement your custom code, but the Linq to Sql visual editor doesn't support it so you must edit your .dbml file manually.
In visual studio you can right-click the .dbml file in the solution explorer, select Open With, and then Xml Editor.
Now you can add the EntityBase
attribute to the <Database>
tag. The EntityBase attribute should contain the name of your common base class.
Finally you should right-click the .dbml file in the solution explorer and select Run Custom Tool. This will recreate your entity classes with the common base class.
Upvotes: 3
Reputation: 422102
It's not suggested to change the generated file directly as it will be regenerated and overwrite your changes if you edit the DBML. The generated classes will be declared as partial
so you can change them by creating another file and declaring a partial
class with the same name and adding your changes there.
Upvotes: 9