I have two entities. Profile and ProfileImages. After fetching a Profile I want to delete ProfileImages through Profile without it just removing the reference to Profile (setting it to null). How can this be done with fluent API and Cascading Delete? Do I set the HasRequired attribute or the CascadeDelete attribute?
public class Profile
{
//other code here for entity
public virtual ICollection<ProfileImage> ProfileImages { get; set; }
}
public class ProfileImage
{
// other code here left out
[Index]
public string ProfileRefId { get; set; }
[ForeignKey("ProfileRefId")]
public virtual Profile Profile { get; set; }
}