Hi
Two questions here
Firstly, I am trying to remove the cascade delete conventions using modelBuilder.Conventions.Remove<OneToManyCascadeDeleteConvention>()
However it gives me a migration file with the following entries
public override void Up() { DropForeignKey("dbo.AbpFeatures", "EditionId", "dbo.AbpEditions"); DropForeignKey("dbo.AbpPermissions", "RoleId", "dbo.AbpRoles"); DropForeignKey("dbo.AbpUserClaims", "UserId", "dbo.AbpUsers"); DropForeignKey("dbo.AbpUserLogins", "UserId", "dbo.AbpUsers"); DropForeignKey("dbo.AbpPermissions", "UserId", "dbo.AbpUsers"); DropForeignKey("dbo.AbpUserRoles", "UserId", "dbo.AbpUsers");
AddForeignKey("dbo.AbpFeatures", "EditionId", "dbo.AbpEditions", "Id");
AddForeignKey("dbo.AbpPermissions", "RoleId", "dbo.AbpRoles", "Id");
AddForeignKey("dbo.AbpUserClaims", "UserId", "dbo.AbpUsers", "Id");
AddForeignKey("dbo.AbpUserLogins", "UserId", "dbo.AbpUsers", "Id");
AddForeignKey("dbo.AbpPermissions", "UserId", "dbo.AbpUsers", "Id");
AddForeignKey("dbo.AbpUserRoles", "UserId", "dbo.AbpUsers", "Id");
}
Hence it is removing the cascade deletes from some core tables that came with Aspnet boiler plate, which I don't want to do. To overcome this behavior I added this piece of code below after the call to modelBuilder.Conventions.Remove<OneToManyCascadeDeleteConvention>();
modelBuilder.Entity<Role>().HasMany(r => r.Permissions).WithRequired().WillCascadeOnDelete(true);
modelBuilder.Entity<User>().HasMany(u => u.Roles).WithRequired().WillCascadeOnDelete(true);
modelBuilder.Entity<User>().HasMany(u => u.Permissions).WithRequired().WillCascadeOnDelete(true);
modelBuilder.Entity<User>().HasMany(u => u.Logins).WithRequired().WillCascadeOnDelete(true);
modelBuilder.Entity<User>().HasMany(u => u.Claims).WithRequired().WillCascadeOnDelete(true);
This works and now the only entry I get in the migration file is DropForeignKey("dbo.AbpFeatures", "EditionId", "dbo.AbpEditions"); AddForeignKey("dbo.AbpFeatures", "EditionId", "dbo.AbpEditions", "Id");
Basically, this is because I have not been able to locate the AbpFeature and AbpEdition tables that have access to the Edition Id and the Edition collection. Can you refer me to the code classes for these tables.
Secondly, where do I view the logs. There is a logs.txt on my dev environment, but cannot seem to find this file on production (IIS). Is there a config setting that I have to change somewhere for logs to be displayed on the server. I see there is a AbpAuditLogs table in the database, however it does not store the errors that are thrown when incorrect data is passed through the REST api in swagger.
Thanks for all the help..
6 Answer(s)
-
0
Can someone help out with this please.
-
0
Hi,
For the first problem, you need to use EditionFeatureSetting entity. For the second problem, if you deployed log4net.config file, it should contain the logs.txt file path. Maybe you don't have write access to directory which must contains Logs.txt.
-
0
Thank you very much for this.
I think the write permission is the reason for the log file not being deployed.
However, with regards to the first problem, I still cannot make the cascade delete false.
modelBuilder.Entity<EditionFeatureSetting>().HasMany(r => r.Edition).WithRequired().WillCascadeOnDelete(true);
Had there been a ICollection<Feature> property this would have worked. Edition is not a collection (since the relationship between edition and feature is one to many) and this does not compile.
-
0
Hi,
The easiest way is to remove content of your migration. What do you think ?
-
0
The only problem with that approach would be that if the migration files are lost, the change is going to be lost too.. See if you or someone in the team can come up with a solution, otherwise we will just let cascade delete to be set to false for this one table. It shouldn't affect the app in any ways.
Regards
-
0
You are right. Then you can leave it like that, it will not be a problem for ABP.