The following code works to set the value of an Entity's column to NULL
Dim Survey = New TransitionDL.EntityClasses.SurveyEntity(SurveyId)
'-- Make sure we actually have a survey object
If Not Survey Is Nothing AndAlso Survey.Fields.State = Fetched Then
'-- Get all of the survey values
Dim StatusCodeId As String = Nothing
'-- Populate the survey entity
Survey.StatusCodeId = StatusCodeId
'-- Save the entity
Survey.Save()
End If
However, if you notice, I did not give the 'Survey' variable a type. When I caught this, I modified the code to this:
Dim Survey As TransitionDL.EntityClasses.SurveyEntity = New TransitionDL.EntityClasses.SurveyEntity(SurveyId)
'-- Make sure we actually have a survey object
If Not Survey Is Nothing AndAlso Survey.Fields.State = Fetched Then
'-- Get all of the survey values
Dim StatusCodeId As String = Nothing
'-- Populate the survey entity
Survey.StatusCodeId = StatusCodeId
'-- Save the entity
Survey.Save()
End If
When I do this, I get a SQL foreign key constraint violation. The generated update statement is passing a value of 0 for this column instead of NULL. In the designer, both the 'IsNullable' and 'Generate As Nullable Type' are checked. Also, the database allows NULLS for this column.
What am I missing?