views:

76

answers:

1

I like Linq but find that once the designer has created my classes I have to modify them. Then when I change my database and recreate my classes in the designer my changes get wiped.

For instance, let's say I have a class called Person. I create this class, add some non database related methods to it (outside of Linq) and then create a database table with a similar name. Linq will duplicate this class in the designer.cs file when I drag it in.

So I go and add the partial keyword to the class in that file or even change the class name Linq created. As development proceeds, no doubt the database table changes and I have to redrag my tables into the designer. Voila, my manual changes get wiped.

This is most annoying! In fact, its unworkable to keep modifying code I have already modified.

Any suggestions?

+3  A: 

Create a partial class for your context and make your changes there, the designer generated .cs files are recreated every time you click save.

Quintin Robinson