I am writing a move method. My many to many table has more data then the two foreign keys so I thought I would update one of the foreign keys to move the record. The two foreign keys combine to make the only primary key for the table. I get a where clause error when trying to do this. I am using EntitySpaces 2007 with SQL Server 2005.
My code:
Code:
public void MoveSafetyFeatureTo(int oldSafetyFeatureId, int newSafetyFeatureId)
{
VehicleSafetyFeatures feature = new VehicleSafetyFeatures();
feature.LoadByPrimaryKey(this.Id.Value, oldSafetyFeatureId);
feature.SafetyFeatureId = newSafetyFeatureId;
feature.Save();
}
Update sql from profiler:
Code:
exec sp_executesql N'SET NOCOUNT OFF UPDATE [VehicleSafetyFeatures] SET WHERE ([VehicleId] = @VehicleId AND
[SafetyFeatureId] = @SafetyFeatureId)',N'@VehicleId int,@SafetyFeatureId
int',@VehicleId=5485,@SafetyFeatureId=71
I guess the primary key is not updated at all? Is this a problem or should I just move to a clone, delete, and add method of moving the record?