The DeleteOnNull attribute is always deleted from the constructor file.

I have a number of associations in my LinqToSql constructor file that I had to add to the DeleteOnNull attribute. However, if I change something through the GUI, then the constructor file is recreated, and I lose the DeleteOnNull attributes.

Anyway, can I stop this?

+4
source share
1 answer

To add the DeleteOnNull attribute, you need to edit your .dbml file directly . To do this, go to it using Windows Explorer and open it in Notepad (or something else - just not Visual Studio). Then edit the association and add the DeleteOnNull attribute, as shown below. Then, the next time you open the dbml constructor in Visual Studio, it should follow your changes and include your attribute in the .Designer.cs file.

.dbml direct (Notepad):

<Association Name="Employee_EmployeeAddress" Member="Employee" ThisKey="EmployeeID" Type="Employee" IsForeignKey="true" DeleteOnNull="true" /> 

The attribute generated in the .Designer.cs file after saving to the dbml designer in Visual Studio (which causes the .Designer.cs file to be restored):

 [Association(Name="Employee_EmployeeAddress", Storage="_Employee", ThisKey="EmployeeID", IsForeignKey=true, DeleteOnNull=true)] 

Hope this helps!

And here is a related discussion , FYI.

+5
source

All Articles