I tried that. It did indeed set the values, but it overrides the fetched values as well (for existing entities). I even tried checking for IsNew but that always appears to be true at the time of OnInitalized, so it seems not to have an effect.
//THIS IS NOT RIGHT
partial class ExecDeviceRouteEntity
{
protected override void OnInitialized()
{
base.OnInitialized();
if (IsNew) // always appears to be true in my testing
{
Priority = 1;
AllowPolling = true;
}
}
}
This results in Priority=1 and AllowPolling=true, even if the persisted values in the DB are different (not good!)
After trying that, I had a better idea of what to search for, and finally I found a post (http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=14456&StartAtMessage=0𓬏), in which Frans suggests this:
protected override void OnInitialized()
{
base.OnInitialized();
if((this.Fields!=null) && (this.Fields.State!=EntityState.Fetched))
{
//SET DEFAULTS HERE
Priority = 1;
AllowPolling = true;
}
}
This appears to be accomplishing what I need. Thanks for your response, and pointing me in the right direction.