Bi-directional serialization stopped working

Apr 5, 2010 at 6:39 PM

I've generated some code that used to give me serialization for both lists of objects that relate to a class's primary key (which still works), and the single object that relates to a foreign key, which is now broken. The generator gives me the following:

 

 

partial void OnApplicationIDChanging(int value);
partial void OnApplicationIDChanged();
private int _ApplicationID;
[Column(Storage=@"_ApplicationID", DbType=@"Int NOT NULL", CanBeNull=false)]
[DataMember(Order=2)]
public int ApplicationID
{
    get { return _ApplicationID; }
    set {
        if (_ApplicationID != value) {
            if (_Application.HasLoadedOrAssignedValue) {
                throw new ForeignKeyReferenceAlreadyHasValueException();
            }
            OnApplicationIDChanging(value);
            SendPropertyChanging();
            _ApplicationID = value;
            SendPropertyChanged("ApplicationID");
            OnApplicationIDChanged();
        }
    }
}

private EntityRef<Application> _Application;
[Association(Name=@"Application_ApplicationExecution", Storage=@"_Application", ThisKey=@"ApplicationID", OtherKey=@"ApplicationID", IsForeignKey=true)]
public Application Application
{
    get {
        return _Application.Entity;
    }
    set {
        Application previousValue = _Application.Entity;
        if ((previousValue != value) || (!_Application.HasLoadedOrAssignedValue)) {
            SendPropertyChanging();
            if (previousValue != null) {
                _Application.Entity = null;
                previousValue.ApplicationExecutions.Remove(this);
            }
            _Application.Entity = value;
            if (value != null) {
                value.ApplicationExecutions.Add(this);
                _ApplicationID = value.ApplicationID;
            }
            else {
                _ApplicationID = default(int);
            }
            SendPropertyChanged("Application");
        }
    }
}

That code is part of my ApplicationExecption class, which has an Appilcation property. That property is correctly populated on my server when I make a request, but after a WCF service call, the property is null. I'm pretty sure the generator is creating the correct code to handle the bi-directional serialization. I can't really figure out what is wrong, here.