/// <summary>
            /// Update the specified object
            /// </summary>
            protected override TModel UpdateInternal(SQLiteDataContext context, TModel data)
            {
                if (data.IsEmpty())
                {
                    return(data);
                }

                foreach (var rp in this.m_properties)
                {
                    var instance = rp.GetValue(data);
                    if (instance != null && rp.Name != "SourceEntity") // HACK: Prevent infinite loops on associtive entities
                    {
                        instance = ModelExtensions.TryGetExisting(instance as IIdentifiedEntity, context);
                        if (instance != null)
                        {
                            rp.SetValue(data, instance);
                        }
                        ModelExtensions.UpdateParentKeys(data, rp);
                    }
                }
                return(base.UpdateInternal(context, data));
            }
            /// <summary>
            /// Ensure exists
            /// </summary>
            protected override TModel InsertInternal(SQLiteDataContext context, TModel data)
            {
                foreach (var rp in typeof(TModel).GetRuntimeProperties().Where(o => typeof(IdentifiedData).GetTypeInfo().IsAssignableFrom(o.PropertyType.GetTypeInfo())))
                {
                    if (rp.GetCustomAttribute <DataIgnoreAttribute>() != null)
                    {
                        continue;
                    }

                    var instance = rp.GetValue(data);
                    if (instance != null)
                    {
                        instance = ModelExtensions.TryGetExisting(instance as IIdentifiedEntity, context);
                        if (instance != null)
                        {
                            rp.SetValue(data, instance);
                        }
                        ModelExtensions.UpdateParentKeys(data, rp);
                    }
                }
                return(base.InsertInternal(context, data));
            }
            /// <summary>
            /// Ensure exists
            /// </summary>
            protected override TModel InsertInternal(SQLiteDataContext context, TModel data)
            {
                if (data.IsEmpty())
                {
                    return(data);
                }

                foreach (var rp in this.m_properties)
                {
                    var instance = rp.GetValue(data);
                    if (instance != null)
                    {
                        instance = ModelExtensions.TryGetExisting(instance as IIdentifiedEntity, context);
                        if (instance != null)
                        {
                            rp.SetValue(data, instance);
                        }

                        ModelExtensions.UpdateParentKeys(data, rp);
                    }
                }
                return(base.InsertInternal(context, data));
            }