-1

Whenever a Linq data context is updated, all manually set attribute parameters are lost. I wonder if there is a way to persist them somehow? For instance, we need to persist an Auto Generated Value property represented by a IsDbGenerated attribute parameter of a ColumnAttribute, which is used, for example, for auto incrementing ID column.

Thanks in advance.

Andrei
  • 55,890
  • 9
  • 87
  • 108
  • @Kirk, by "manually" I do not mean setting its properties on runtime. Just setting the value in data context designer. For instance, Auto Generated Value is by default set to false, and you can set it to true to specify that this column will be generated by the database during the insert process. – Andrei Jul 08 '11 at 15:27

1 Answers1

0

You can't manually edit the designer.cs file and expect your changes to persist after you have updated something using the designer, however you can control the values of all of the auto generated parameters via the designer and these changes are persisted so long as you don't delete and re add the table/class.

If you want to add custom attributes unrelated to LinqToSql you can take advantage of the fact that the LinqToSql classes are all partial classes. Move the properties into another file that continues the partial class. This will then get left alone when you update the designer file. However you will have to manage any database changes to the that need to be reflected on these properties manually and not through the designer.

Ben Robinson
  • 21,601
  • 5
  • 62
  • 79