I have following entities:
public class BaseEntity
{
[Key]
public long Id { get; set; }
}
public class Tenant : BaseEntity
{
public virtual Nullable<long> SQLDatabaseId { get; set; }
public virtual SQLDatabase SQLDatabase { get; set; }
public virtual Nullable<long> StorageAccountId { get; set; }
public virtual StorageAccount StorageAccount { get; set; }
}
public class SQLDatabase : BaseEntity
{
public virtual long TenantId { get; set; }
public virtual Tenant Tenant { get; set; }
}
public class StorageAccount : BaseEntity
{
public virtual long TenantId { get; set; }
public virtual Tenant Tenant { get; set; }
}
And in OnModelCreating with fulent API
modelBuilder.Entity<SQLDatabase>()
.HasRequired(r => r.Tenant);
modelBuilder.Entity<StorageAccount>()
.HasRequired(r => r.Tenant);
Now when I run the project it creates database with strange way
It creates a one to one relation from Tenant to SQLDatabase which is OK, but when I see that in SSMS, this relationship is from Tenant.Id to SQLDatabase.Id
Which isn't true. A tenant is mandatory for creating SQL database and Storage Account and also that the relationship is 1:1 in either case.
You should specify which is Principal and which is Dependent. Try follwoing:
modelBuilder.Entity<SQLDatabase>()
.HasRequired(r => r.Tenant)
.WithRequiredDependent(m => m.SQLDatabase);
modelBuilder.Entity<StorageAccount>()
.HasRequired(r => r.Tenant)
.WithRequiredDependent(m => m.StorageAccount);
Related
I'm using Net Core 2.2 and Entity Framework. I have an ApplicationUser class used for multiple user types with foreign keys to each other but entity framework gives an error when adding a migration:
Unable to determine the relationship represented by navigation property 'ApplicationUser.Class' of type 'Class'. Either manually configure the relationship, or ignore this property using the '[NotMapped]' attribute or by using 'EntityTypeBuilder.Ignore' in 'OnModelCreating'.
I'm unsure what the proper way to implement this is. Can anyone help me?
My ApplicationUser class:
public class ApplicationUser : IdentityUser
{
public string CustomerId { get; set; }
public string TeacherId { get; set; }
public int? ClassId { get; set; }
public int? SettingsId { get; set; }
public virtual ApplicationUser Customer { get; set; }
public virtual ApplicationUser Teacher { get; set; }
public virtual Class Class { get; set; }
public virtual Settings Settings { get; set; }
public virtual ICollection<Class> Classes { get; set; }
public virtual ICollection<License> Licenses { get; set; }
public virtual ICollection<Exercise> Exercises { get; set; }
public virtual ICollection<GameProgress> GameProgresses { get; set; }
public virtual ICollection<StudentExercise> StudentExercises { get; set; }
}
And because it's in the error, my Class class:
public class Class
{
public int Id { get; set; }
public string TeacherId { get; set; }
public int? SettingsId { get; set; }
public virtual ApplicationUser Teacher { get; set; }
public virtual Settings Setting { get; set; }
public virtual ICollection<Exercise> Exercises { get; set; }
public virtual ICollection<ApplicationUser> Students { get; set; }
}
The problem has nothing to do with self-referential ApplicationUser relationships. The exception specifically tells you this is a problem with Class. The issue is that you've got a reference property to Class on ApplicationUser, but on Class, you've got both a collection of ApplicationUsers (Students) and a separate reference to ApplicationUser (Teacher). Simply, EF doesn't know which this foreign key is actually referring to.
The solution is exactly what the exception tells you: add fluent config to clear up the ambiguity:
public override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<ApplicationUser>()
.HasOne(x => x.Class)
.WithMany(x => x.Students);
}
I have the following situation: I have a class Company, it is as simple as possible
public class Company
{
public int ID { get; set; }
public string Name { get; set; }
}
I also need to extend the IdentityUser class from ASP. NET Identity Core:
public class User : IdentityUser
{
public Company Company { get; set; }
public int CompanyID { get; set; }
}
Not bad so far. But I also need a class Device :
public class Device
{
public Company Company { get; set; }
public int CompanyID { get; set; }
}
Accordingly, we add the Devices property of the List<Device> type to the Company class and Users property of the List<User> type.
The problem is that I want to separate the data (Device table) from the data of ASP .NET Identity Core in different databases. Table Company I want to put in the database with Auth data. And table Device in other one. How can I tell the Entity Framework that the Company property of the Device class is from another database?
If the Company property is from another database, you may need to add a second database context for it, if you haven't already. Something like this:
public class CompanyModelContext : DbContext
{
public CompanyModelContext(DbContextOptions options) : base(options){ }
public DbSet<Company> Company { get; set; }
}
You can try to set your EF model like this:
Companies table:
[Table("Companies")]
public class Company
{
[Key]
public int ID { get; set; }
public string Name { get; set; }
public ICollection<Device> Devices { get; set; }
}
Devices table:
[Table("Devices")]
public class Device
{
[Key]
public int Id { get; set; }
public Company Company { get; set; }
public int CompanyID { get; set; }
}
ApplicationDbContext class:
public DbSet<Company> Companies { get; set; }
public DbSet<Device> Devices { get; set; }
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
builder.Entity<Company>(buildAction =>
{
buildAction.ToTable("Companies");
buildAction.HasMany(x => x.Devices)
.WithOne(x => x.Company)
.OnDelete(DeleteBehavior.Cascade);
};
}
I've added Devices as a list in Company class, then overriding the FK in the method OnModelCreating.
Once you delete an item in table Company, all items with the same Id in table Devices (comparing to CompanyID) will be delted automatically.
Since we use the 2 properties [Table] and [Key] to define table name and the primary key. So in the OnModelCreating, you can ignore to define the name, PK, FK of table Device.
Company has many User
In this case:
User class:
public class User : IdentityUser
{
public int CompanyId { get; set; }
public Company Company { get; set; }
}
Company class:
[Table("Companies")]
public class Company
{
[Key]
public int ID { get; set; }
public string Name { get; set; }
public ICollection<Device> Devices { get; set; }
public ICollection<User> Users { get; set; }
}
ApplicationDbContext class:
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
builder.Entity<Company>(buildAction =>
{
buildAction.ToTable("Companies");
buildAction.HasMany(x => x.Devices)
.WithOne(x => x.Company)
.OnDelete(DeleteBehavior.Cascade);
buildAction.HasMany(x => x.Users)
.WithOne(x => x.Company)
.OnDelete(DeleteBehavior.Cascade);
};
}
I have a POCO Entity named Employee.
And then I have a second POCO Entity named Case.
I want a navigation property that looks like instead this:
public class Case : BaseEntity
{
public long EmployeeId { get; set; }
public virtual Employee Employee{ get; set; }
like this:
public class Case : BaseEntity
{
public long InitialContactId { get; set; }
public virtual Employee InitialContact { get; set; }
I want to name my property InitialContact. Not Employee.
But I get this error when EF tries to create the Database:
Unable to determine the relationship represented by navigation property 'Case.InitialContact' of type 'Employee'. Either manually configure the relationship, or ignore this property from the model.
Update 1:
I got it to work like this:
public class Case : BaseEntity
{
public long InitialContactId { get; set; }
[ForeignKey("Id")]
public virtual Employee InitialContact { get; set; }
public DateTime InitalConsultDate { get; set; }
public Guid AppUserId { get; set; }
public virtual AppUser LerSpecialist { get; set; }
}
The primary key is ID in my BaseEntity. Not EmployeeId.
But I have second part to my question.
Here is my Complete Employee POCO:
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using Hrsa.Core.Generic.Model.Framework.Concrete;
using Microsoft.AspNetCore.Mvc.ModelBinding;
namespace Hrsa.Core.Generic.Model.Lerd
{
public class Employee : BaseEntity
{
[BindNever]
public string Email { get; set; }
[BindNever]
public long OrganizationId { get; set; }
[BindNever]
public string Supervisor { get; set; }
[BindNever]
public string SupervisorEmail { get; set; }
[BindNever]
public string FirstName { get; set; }
[BindNever]
public string LastName { get; set; }
public string Notes { get; set; }
[BindNever]
public long BargainingUnitId { get; set; }
[BindNever]
public long PayPlanId { get; set; }
[BindNever]
public long GradeRankId { get; set; }
[BindNever]
public long PositionTitleId { get; set; }
[BindNever]
public long SeriesId { get; set; }
public bool IsUnionEmployee { get; set; }
public virtual Organization Organization { get; set; }
public virtual BargainingUnit BargainingUnit { get; set; }
public virtual PayPlan PayPlan { get; set; }
public virtual GradeRank GradeRank { get; set; }
public virtual PositionTitle PositionTitle { get; set; }
public virtual Series Series { get; set; }
public virtual ICollection<UnionHours> UnionHours { get; set; }
public virtual ICollection<Case> Cases { get; set; }
[NotMapped]
public string UnionEmployeeYesNo => (IsUnionEmployee) ? "Yes" : "No";
}
}
I want my Employee to have many Cases:
public virtual ICollection<Case> Cases { get; set; }
Here is my complete Cases POCO:
public class Case : BaseEntity
{
public long InitialContactId { get; set; }
[ForeignKey("Id")]
public virtual Employee InitialContact { get; set; }
public DateTime InitalConsultDate { get; set; }
public Guid AppUserId { get; set; }
public virtual AppUser LerSpecialist { get; set; }
}
So now my DB looks like this:
So I have my InitialContactId in Cases ok.
But now I need my Case to have many Employees.
So I add this in to my Case POCO:
public virtual ICollection<Employee> Employees { get; set; }
Now it looks like this:
public class Case : BaseEntity
{
public long InitialContactId { get; set; }
[ForeignKey("Id")]
public virtual Employee InitialContact { get; set; }
public DateTime InitalConsultDate { get; set; }
public Guid AppUserId { get; set; }
public virtual AppUser LerSpecialist { get; set; }
public virtual ICollection<Employee> Employees { get; set; }
}
Now when I run it, I get this error again:
Unable to determine the relationship represented by navigation property 'Case.InitialContact' of type 'Employee'. Either manually configure the relationship, or ignore this property from the model.
Update 2:
I found this article for a Many-Many relationship in .Net Core 1:
http://www.learnentityframeworkcore.com/configuration/many-to-many-relationship-configuration
So now I have a bridge lookup entity:
public class EmployeeCase
{
[ForeignKey("Id")]
public long EmployeeId { get; set; }
public Employee Employee { get; set; }
[ForeignKey("Id")]
public long CaseId { get; set; }
public Case Case { get; set; }
}
Employee POCO:
Changed:
public virtual ICollection<Case> Cases { get; set; }
to:
// Mapping - Collection of Cases
public virtual ICollection<EmployeeCase> EmployeeCases { get; set; }
Case POCO:
Changed:
public virtual ICollection<Employee> Employees { get; set; }
to:
// Mapping - Collection of Employees
public virtual ICollection<EmployeeCase> EmployeeCases { get; set; }
In my AppDbContext
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
#region Many-to-Many Employees Cases
modelBuilder.Entity<EmployeeCase>()
.HasKey(ec => new { ec.EmployeeId, ec.CaseId });
modelBuilder.Entity<EmployeeCase>()
.HasOne(ec => ec.Employee)
.WithMany(e => e.EmployeeCases)
.HasForeignKey(ec => ec.EmployeeId);
modelBuilder.Entity<EmployeeCase>()
.HasOne(ec => ec.Case)
.WithMany(c => c.EmployeeCases)
.HasForeignKey(ec => ec.CaseId);
#endregion
}
Now when I run I get this error:
An exception of type 'System.Data.SqlClient.SqlException' occurred in Microsoft.EntityFrameworkCore.Relational.dll but was not handled in user code
Additional information: Introducing FOREIGN KEY constraint 'FK_EmployeeCase_Employees_EmployeeId' on table 'EmployeeCase' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints.
Could not create constraint or index. See previous errors.
Update 3:
Finally got my tables the way I want with this piece of code from:
Introducing FOREIGN KEY constraint may cause cycles or multiple cascade paths - why?
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
// Get rid of Cascading Circular error on ModelBuilding
foreach (var relationShip in modelBuilder.Model.GetEntityTypes().SelectMany(e => e.GetForeignKeys()))
{
relationShip.DeleteBehavior = DeleteBehavior.Restrict;
}
#region Many-to-Many Employees Cases
modelBuilder.Entity<EmployeeCase>()
.HasKey(ec => new { ec.EmployeeId, ec.CaseId });
modelBuilder.Entity<EmployeeCase>()
.HasOne(ec => ec.Employee)
.WithMany(e => e.EmployeeCases)
.HasForeignKey(ec => ec.EmployeeId);
modelBuilder.Entity<EmployeeCase>()
.HasOne(ec => ec.Case)
.WithMany(c => c.EmployeeCases)
.HasForeignKey(ec => ec.CaseId);
#endregion
base.OnModelCreating(modelBuilder);
}
Update 4:
This did not work after all.
Remvoving the delete behavior for everything messes up my other relationships and I get errors.
How can I fix this?
This is disgusting.
So wishing I did not go Core.
Entity Framework uses conventions to guess how to map your C# model to database objects.
In your case you violate convention by custom name, so you should explain Entity Framework how to map this stuff.
There are two possible ways: attributes and fluent API. I'd suggest to use the latter one.
See section "Configuring a Foreign Key Name That Does Not Follow the Code First Convention" here: Entity Framework Fluent API - Relationships
I have made it a habit of explicitly defining my relationships as EF does not always get them the way I want. I like to create a Mapping folder that contains my entity maps. The fluent api works great for this and inherits from EntityTypeConfiguration.
Try this.
public class CaseMap : EntityTypeConfiguration<Case>
{
public CaseMap()
{
HasKey(m => m.Id)
HasRequired(m => m.InitialContact)
.WithMany(e => e.Cases)
.HasForeignKey(m => m.InitialContactId);
}
}
Almost forgot. You need to tell your DbContext where to find these mappings. Add this to your DbContexts OnModelCreating method.
modelBuilder.Configurations.AddFromAssembly(typeof(MyContext).Assembly);
This is what worked finally for the Cascading Delete circular references on the many-to-many in EF Core:
// Get rid of Cascading Delete Circular references error.
var type = modelBuilder.Model.GetEntityTypes().Single(t => t.Name == "Hrsa.Core.Generic.Model.Lerd.EmployeeCase");
foreach (var relationship in type.GetForeignKeys())
{
relationship.DeleteBehavior = DeleteBehavior.Restrict;
}
You have to get the Entity representing the many to many lookup only.
And from there restrict the DeleteBehavior.
I've just started a new project in Web Forms because I thought it'd be quicker than learning MVC, but how wrong was I! I'm struggling with the Identity aspect of my project. I've followed this link here: http://www.asp.net/identity/overview/extensibility/change-primary-key-for-users-in-aspnet-identity
And it all compiles ok and works (my ID column is now an integer).
So I've created a new class for a 'Property' context:
using System.Collections.Generic;
using System.Data.Entity;
using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Identity.Owin;
using Microsoft.AspNet.Identity.EntityFramework;
using System.Web.Security;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration.Conventions;
namespace MyApp.Models
{
public class PropertyContext : DbContext
{
public PropertyContext()
: base("DefaultConnection")
{
}
public DbSet<Property> Property { get; set; }
}
public class Property
{
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity), ScaffoldColumn(false)]
public int PropertyID { get; set; }
//[Required, StringLength(128)]
//public string OwnerID { get; set; }
// [ForeignKey("OwnerID")]
//public virtual ApplicationUser ApplicationUser { get; set; }
//[ForeignKey("OwnerID")]
//public int OwnerID { get; set; }
// public virtual ApplicationUser ApplicationUser { get; set; }
public int OwnerID { get; set; }
[ForeignKey("OwnerID")]
public virtual ApplicationUser ID { get; set; }
[Required, StringLength(255), Display(Name = "Address 1")]
public string Address1 { get; set; }
[Required, StringLength(255), Display(Name = "Address 2")]
public string Address2 { get; set; }
[Required, StringLength(255), Display(Name = "Address 3")]
public string Address3 { get; set; }
[Required, StringLength(255), Display(Name = "Town/City")]
public string Settlement { get; set; }
[Required, StringLength(255), Display(Name = "County")]
public string County { get; set; }
[Required, StringLength(255), Display(Name = "Post Code")]
public string PostCode { get; set; }
[Required, StringLength(255), Display(Name = "Country")]
public string Country { get; set; }
}
}
Whereby I'm trying to make a new int column called 'OwnerID' a foreign key into the 'AspNetUser' table's ID column. When i build my project, it builds fine. However when I try to add a migration I get this:
MyApp.Models.CustomUserLogin: : EntityType 'CustomUserLogin' has no key defined. Define the key for this EntityType.
MyApp.Models.CustomUserRole: : EntityType 'CustomUserRole' has no key defined. Define the key for this EntityType.
CustomUserLogins: EntityType: EntitySet 'CustomUserLogins' is based on type 'CustomUserLogin' that has no keys defined.
CustomUserRoles: EntityType: EntitySet 'CustomUserRoles' is based on type 'CustomUserRole' that has no keys defined.
So in my ApplicationDbContext I've added this:
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<ApplicationUser>().ToTable("Users").HasKey<int>(u => u.Id);
modelBuilder.Entity<CustomUserRole>().ToTable("UserRoles").HasKey(ur => new { ur.RoleId, ur.UserId });
modelBuilder.Entity<CustomUserLogin>().ToTable("UserLogins").HasKey<int>(ul => ul.UserId);
modelBuilder.Entity<CustomUserClaim>().ToTable("UserClaims").HasKey<int>(uc => uc.Id);
modelBuilder.Entity<CustomRole>().ToTable("Roles").HasKey<int>(r => r.Id);
}
and even this
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<CustomUserLogin>().HasKey(cul => cul.UserId);
modelBuilder.Entity<CustomUserRole>().HasKey(cur => cur.UserId);
But it still doesn't work. And to be quite honest I'm burning up a whole weekend by stabbing in the dark. I can't believe something as simple as creating a foreign key is so difficult in this Entity Framework environment.
Can anybody give me a pointer? Thanks.
I did exactly as you did.
Added Identity to my MVC Web Application
Changed the primary key to be an INT rather a GUID
Added an EmployeeProfile and a CustomerProfile to the ApplicationUser
I did not have to override OnModelCreating as I made my own changes to the database tables to support what I needed.
Added two new properties to the ApplicationUser class in IdentityModels.cs
public virtual CustomerProfile CustomerProfile { get; set; }
public virtual EmployeeProfile EmployeeProfile { get; set; }
I created the CustomerProfile and EmployeeProfile classes. Note the Data Annotations on the Id property of each class. The Id property is the ForeignKey property to guide the virtual User property back to the ApplicationUser.
public class EmployeeProfile
{
[Key, ForeignKey("User")]
public int Id { get; set; }
public DateTime HireDate { get; set; }
public DateTime BirthDate{ get; set; }
public virtual ApplicationUser User { get; set; }
}
public class CustomerProfile
{
[Key, ForeignKey("User")]
public int Id { get; set; }
public CustomerType CustomerType { get; set; }
public string Company { get; set; }
public string Address { get; set; }
public string City { get; set; }
public string State { get; set; }
public string ZipCode { get; set; }
public string WorkPhone { get; set; }
public string CustomerId { get; set; }
public string AccountType { get; set; }
public virtual ApplicationUser User { get; set; }
}
In my ApplicationDbContext class, I added the following lines of code:
public DbSet<CustomerProfile> CustomerProfile { get; set; }
public DbSet<EmployeeProfile> EmployeeProfile { get; set; }
Everything was working as expected. I logged in and saw the Customer and Employee info in my views.
I started seeing the error you received "EntityType 'CustomUserLogin' has no key defined. Define the key for this EntityType" when I added a many to many relation ship in the EmployeeProfile class to a Departments class. In my scenario an Employee can belong to 1 or many departments and a department can have many employees. My database changes were good and even the classes compiled just like you experienced, however once I ran the project, the website would error out.
Backing out my changes resolved the issue. Something in my classes was throwing off the validation of the model, so I'll need to approach the problem differently. So just like in my case, your poco classes may have an issue.
Remove your 'Property' class and references. Make the project work with the base essentials. Once you have it working, add the Property class back in with just the Id property.
Let me know if you still need help.
Place the base.OnModelCreating at the bottom:
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
modelBuilder.Entity<ApplicationUser>().ToTable("Users").HasKey<int>(u => u.Id);
modelBuilder.Entity<CustomUserRole>().ToTable("UserRoles").HasKey(ur => new { ur.RoleId, ur.UserId });
modelBuilder.Entity<CustomUserLogin>().ToTable("UserLogins").HasKey<int>(ul => ul.UserId);
modelBuilder.Entity<CustomUserClaim>().ToTable("UserClaims").HasKey<int>(uc => uc.Id);
modelBuilder.Entity<CustomRole>().ToTable("Roles").HasKey<int>(r => r.Id);
base.OnModelCreating(modelBuilder);
}
This is scenario one, which works fine:
public class Domain
{
public int DomainId { get; set; }
[InverseProperty("Domain")]
public virtual ICollection<Person> Persons { get; set; }
[InverseProperty("Domain")]
public virtual ICollection<Group> Groups { get; set; }
}
public class Person
{
public int PersonId { get; set; }
public virtual Domain Domain { get; set; }
public virtual ICollection<Group> Groups { get; set; }
}
public class Group
{
public int GroupId { get; set; }
public virtual Domain Domain { get; set; }
public virtual ICollection<Person> Members { get; set; }
}
And this is scenario two, which fails.
public class Domain
{
// Same as scenario 1...
}
public class Person
{
public int PersonId { get; set; }
public int DomainId { get; set; } // <--- new
[ForeignKey("DomainId")] // <--- new
public virtual Domain Domain { get; set; }
public virtual ICollection<Group> Groups { get; set; }
}
public class Group
{
public int GroupId { get; set; }
public int DomainId { get; set; } // <--- new
[ForeignKey("DomainId")] // <--- new
public virtual Domain Domain { get; set; }
public virtual ICollection<Person> Members { get; set; }
}
The error message in scenario 2 is the following:
The referential relationship will result in a cyclical reference that is not allowed. [ Constraint name = FK_dbo.GroupMembers_dbo.Persons_MemberId ]
Both scenarios have this mapping (many to many), inside OnModelCreating's method.
modelBuilder.Entity<Group>()
.HasMany(group => group.Members)
.WithMany(member => member.Groups)
.Map(m =>
{
m.ToTable("GroupMembers");
m.MapLeftKey("GroupId");
m.MapRightKey("MemberId");
});
What am I doing wrong?! What I want to achieve is perfectly reasonable
Either you're using a different version of EF to me (I'm using 5), or you're not including some code which is causing your problem. I created a context containing the code you've provided, and the only error I got was an error about multiple cascade paths (Domains being deleted via Persons or via Groups). I removed Cascade delete on one of the relationships, and it works fine.
Here's my entire context class which works with no errors:
public class TestContext : DbContext
{
public DbSet<Person> People { get; set; }
public DbSet<Group> Groups { get; set; }
public DbSet<Domain> Domains { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Entity<Group>()
.HasMany(group => group.Members)
.WithMany(member => member.Groups)
.Map(m =>
{
m.ToTable("GroupMembers");
m.MapLeftKey("GroupId");
m.MapRightKey("MemberId");
});
modelBuilder.Entity<Domain>()
.HasMany(d => d.Groups).WithRequired(g => g.Domain)
.WillCascadeOnDelete(false);
}
}