我有一个带有Entity Framework 5.0 e Sql Server CE 4.0的.NET4.0应用程序.
我有两个实体,一对多(父/子)关系.我已将其配置为在父删除时级联删除,但由于某种原因它似乎不起作用.
这是我的实体的简化版本:
public class Account
{
public int AccountKey { get; set; }
public string Name { get; set; }
public ICollection<User> Users { get; set; }
}
internal class AccountMap : EntityTypeConfiguration<Account>
{
public AccountMap()
{
this.HasKey(e => e.AccountKey);
this.Property(e => e.AccountKey).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
this.Property(e => e.Name).IsRequired();
}
}
public class User
{
public int UserKey { get; set; }
public string Name { get; set; }
public Account Account { get; set; …Run Code Online (Sandbox Code Playgroud)