i have this entity Page:
public class Page : FullAuditedEntity<int, User>, IMultiLanguageEntity<PageTranslation>
{
public string Name { get; set; }
public string Content{ get; set; }
public Page()
{
Translations = new List<PageTranslation>();
}
public virtual IList<PageTranslation> Translations { get; set; }
}
And entity PageTranslation:
[Table("PageTranslations")]
public class PageTranslation : Entity<int>, IEntityTranslation<Page>
{
public Page Core { get; set; }
public int CoreId { get; set; }
public string Language { get; set; }
public string Name { get; set; }
public string Content{ get; set; }
}
I want to update page entity with updated values and tranlsations, so I call this service:
public void UpdatePage(UpdatePageInput input)
{
var item = _pageRepository.Get(input.Id);
item.Content = input.Content;
item.Description = input.Description;
item.Title = input.Title;
item.Name = input.Name;
item.Translations.Clear(); // there is a problem
item.Translations.addRange(input.Translations);
}
When I call item.Translations.Clear()
method I got this exception:
The operation failed: The relationship could not be changed because one or more of the foreign-key properties is non-nullable. When a change is made to a relationship, the related foreign-key property is set to a null value. If the foreign-key does not support null values, a new relationship must be defined, the foreign-key property must be assigned another non-null value, or the unrelated object must be deleted.
How to solve this in ABP - http://www.aspnetboilerplate.com/?
Thanks for help !