I was trying to move the AbpTables from dbo. to xxx. using the latest changes
protected override void OnModelCreating(DbModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder);
modelBuilder.ChangeAbpTablePrefix<Tenant, Role, User>(string.Empty,"xxx");
}
When I run the migration I get this issue while seeding :
Running Seed method. System.Data.SqlClient.SqlException (0x80131904): Cannot find the object "BackgroundJobs" because it does not exist or you do not have permissions.
ClientConnectionId:5c2bb018-df94-40df-8044-a3dc537b3e1a Error Number:4902,State:1,Class:16
Any Ideas ?
2 Answer(s)
-
0
Can you share the created migration code and table names in your database.
-
0
namespace <<SOMENAME>>.<XXXX>>>.Migrations { using System; using System.Collections.Generic; using System.Data.Entity.Infrastructure.Annotations; using System.Data.Entity.Migrations;
public partial class ForHilkan : DbMigration { public override void Up() { RenameTable(name: "dbo.<<SOMENAME>>_Roles", newName: "Roles"); RenameTable(name: "dbo.<<SOMENAME>>_Users", newName: "Users"); RenameTable(name: "dbo.<<SOMENAME>>_OrganizationUnits", newName: "OrganizationUnits"); RenameTable(name: "dbo.<<SOMENAME>>_UserLogins", newName: "UserLogins"); RenameTable(name: "dbo.<<SOMENAME>>_Permissions", newName: "Permissions"); RenameTable(name: "dbo.<<SOMENAME>>_UserRoles", newName: "UserRoles"); RenameTable(name: "dbo.<<SOMENAME>>_Settings", newName: "Settings"); RenameTable(name: "dbo.<<SOMENAME>>_Tenants", newName: "Tenants"); RenameTable(name: "dbo.<<SOMENAME>>_Editions", newName: "Editions"); RenameTable(name: "dbo.<<SOMENAME>>_AuditLogs", newName: "AuditLogs"); RenameTable(name: "dbo.<<SOMENAME>>_BackgroundJobs", newName: "BackgroundJobs"); RenameTable(name: "dbo.<<SOMENAME>>_Features", newName: "Features"); RenameTable(name: "dbo.<<SOMENAME>>_Languages", newName: "Languages"); RenameTable(name: "dbo.<<SOMENAME>>_LanguageTexts", newName: "LanguageTexts"); RenameTable(name: "dbo.<<SOMENAME>>_Notifications", newName: "Notifications"); RenameTable(name: "dbo.<<SOMENAME>>_NotificationSubscriptions", newName: "NotificationSubscriptions"); RenameTable(name: "dbo.<<SOMENAME>>_UserLoginAttempts", newName: "UserLoginAttempts"); RenameTable(name: "dbo.<<SOMENAME>>_UserNotifications", newName: "UserNotifications"); RenameTable(name: "dbo.<<SOMENAME>>_UserOrganizationUnits", newName: "UserOrganizationUnits"); MoveTable(name: "dbo.Roles", newSchema: "xxx"); MoveTable(name: "dbo.Users", newSchema: "xxx"); MoveTable(name: "dbo.OrganizationUnits", newSchema: "xxx"); MoveTable(name: "dbo.UserLogins", newSchema: "xxx"); MoveTable(name: "dbo.Permissions", newSchema: "xxx"); MoveTable(name: "dbo.UserRoles", newSchema: "xxx"); MoveTable(name: "dbo.Settings", newSchema: "xxx"); MoveTable(name: "dbo.Tenants", newSchema: "xxx"); MoveTable(name: "dbo.Editions", newSchema: "xxx"); MoveTable(name: "dbo.AuditLogs", newSchema: "xxx"); MoveTable(name: "dbo.BackgroundJobs", newSchema: "xxx"); MoveTable(name: "dbo.Features", newSchema: "xxx"); MoveTable(name: "dbo.Languages", newSchema: "xxx"); MoveTable(name: "dbo.LanguageTexts", newSchema: "xxx"); MoveTable(name: "dbo.Notifications", newSchema: "xxx"); MoveTable(name: "dbo.NotificationSubscriptions", newSchema: "xxx"); MoveTable(name: "dbo.UserLoginAttempts", newSchema: "xxx"); MoveTable(name: "dbo.UserNotifications", newSchema: "xxx"); MoveTable(name: "dbo.UserOrganizationUnits", newSchema: "xxx"); CreateTable( "dbo.<<SOMENAME>>_OrganizationUnits", c => new { Id = c.Long(nullable: false), MyId = c.Int(), }, annotations: new Dictionary<string, object> { { "DynamicFilter_OrganizationExtended_MayHaveTenant", "EntityFramework.DynamicFilters.DynamicFilterDefinition" }, { "DynamicFilter_OrganizationExtended_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" }, }) .PrimaryKey(t => t.Id) .ForeignKey("xxx.OrganizationUnits", t => t.Id) .Index(t => t.Id); AlterTableAnnotations( "xxx.OrganizationUnits", c => new { Id = c.Long(nullable: false, identity: true), TenantId = c.Int(), ParentId = c.Long(), Code = c.String(nullable: false, maxLength: 128), DisplayName = c.String(nullable: false, maxLength: 128), IsDeleted = c.Boolean(nullable: false), DeleterUserId = c.Long(), DeletionTime = c.DateTime(), LastModificationTime = c.DateTime(), LastModifierUserId = c.Long(), CreationTime = c.DateTime(nullable: false), CreatorUserId = c.Long(), }, annotations: new Dictionary<string, AnnotationValues> { { "DynamicFilter_OrganizationExtended_MayHaveTenant", new AnnotationValues(oldValue: "EntityFramework.DynamicFilters.DynamicFilterDefinition", newValue: null) }, { "DynamicFilter_OrganizationExtended_SoftDelete", new AnnotationValues(oldValue: "EntityFramework.DynamicFilters.DynamicFilterDefinition", newValue: null) }, }); DropColumn("xxx.OrganizationUnits", "MyId"); DropColumn("xxx.OrganizationUnits", "Discriminator"); } public override void Down() { AddColumn("xxx.OrganizationUnits", "Discriminator", c => c.String(nullable: false, maxLength: 128)); AddColumn("xxx.OrganizationUnits", "MyId", c => c.Int()); DropForeignKey("dbo.<<SOMENAME>>_OrganizationUnits", "Id", "xxx.OrganizationUnits"); DropIndex("dbo.<<SOMENAME>>_OrganizationUnits", new[] { "Id" }); AlterTableAnnotations( "xxx.OrganizationUnits", c => new { Id = c.Long(nullable: false, identity: true), TenantId = c.Int(), ParentId = c.Long(), Code = c.String(nullable: false, maxLength: 128), DisplayName = c.String(nullable: false, maxLength: 128), IsDeleted = c.Boolean(nullable: false), DeleterUserId = c.Long(), DeletionTime = c.DateTime(), LastModificationTime = c.DateTime(), LastModifierUserId = c.Long(), CreationTime = c.DateTime(nullable: false), CreatorUserId = c.Long(), }, annotations: new Dictionary<string, AnnotationValues> { { "DynamicFilter_OrganizationExtended_MayHaveTenant", new AnnotationValues(oldValue: null, newValue: "EntityFramework.DynamicFilters.DynamicFilterDefinition") }, { "DynamicFilter_OrganizationExtended_SoftDelete", new AnnotationValues(oldValue: null, newValue: "EntityFramework.DynamicFilters.DynamicFilterDefinition") }, }); DropTable("dbo.<<SOMENAME>>_OrganizationUnits", removedAnnotations: new Dictionary<string, object> { { "DynamicFilter_OrganizationExtended_MayHaveTenant", "EntityFramework.DynamicFilters.DynamicFilterDefinition" }, { "DynamicFilter_OrganizationExtended_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" }, }); MoveTable(name: "xxx.UserOrganizationUnits", newSchema: "dbo"); MoveTable(name: "xxx.UserNotifications", newSchema: "dbo"); MoveTable(name: "xxx.UserLoginAttempts", newSchema: "dbo"); MoveTable(name: "xxx.NotificationSubscriptions", newSchema: "dbo"); MoveTable(name: "xxx.Notifications", newSchema: "dbo"); MoveTable(name: "xxx.LanguageTexts", newSchema: "dbo"); MoveTable(name: "xxx.Languages", newSchema: "dbo"); MoveTable(name: "xxx.Features", newSchema: "dbo"); MoveTable(name: "xxx.BackgroundJobs", newSchema: "dbo"); MoveTable(name: "xxx.AuditLogs", newSchema: "dbo"); MoveTable(name: "xxx.Editions", newSchema: "dbo"); MoveTable(name: "xxx.Tenants", newSchema: "dbo"); MoveTable(name: "xxx.Settings", newSchema: "dbo"); MoveTable(name: "xxx.UserRoles", newSchema: "dbo"); MoveTable(name: "xxx.Permissions", newSchema: "dbo"); MoveTable(name: "xxx.UserLogins", newSchema: "dbo"); MoveTable(name: "xxx.OrganizationUnits", newSchema: "dbo"); MoveTable(name: "xxx.Users", newSchema: "dbo"); MoveTable(name: "xxx.Roles", newSchema: "dbo"); RenameTable(name: "dbo.UserOrganizationUnits", newName: "<<SOMENAME>>_UserOrganizationUnits"); RenameTable(name: "dbo.UserNotifications", newName: "<<SOMENAME>>_UserNotifications"); RenameTable(name: "dbo.UserLoginAttempts", newName: "<<SOMENAME>>_UserLoginAttempts"); RenameTable(name: "dbo.NotificationSubscriptions", newName: "<<SOMENAME>>_NotificationSubscriptions"); RenameTable(name: "dbo.Notifications", newName: "<<SOMENAME>>_Notifications"); RenameTable(name: "dbo.LanguageTexts", newName: "<<SOMENAME>>_LanguageTexts"); RenameTable(name: "dbo.Languages", newName: "<<SOMENAME>>_Languages"); RenameTable(name: "dbo.Features", newName: "<<SOMENAME>>_Features"); RenameTable(name: "dbo.BackgroundJobs", newName: "<<SOMENAME>>_BackgroundJobs"); RenameTable(name: "dbo.AuditLogs", newName: "<<SOMENAME>>_AuditLogs"); RenameTable(name: "dbo.Editions", newName: "<<SOMENAME>>_Editions"); RenameTable(name: "dbo.Tenants", newName: "<<SOMENAME>>_Tenants"); RenameTable(name: "dbo.Settings", newName: "<<SOMENAME>>_Settings"); RenameTable(name: "dbo.UserRoles", newName: "<<SOMENAME>>_UserRoles"); RenameTable(name: "dbo.Permissions", newName: "<<SOMENAME>>_Permissions"); RenameTable(name: "dbo.UserLogins", newName: "<<SOMENAME>>_UserLogins"); RenameTable(name: "dbo.OrganizationUnits", newName: "<<SOMENAME>>_OrganizationUnits"); RenameTable(name: "dbo.Users", newName: "<<SOMENAME>>_Users"); RenameTable(name: "dbo.Roles", newName: "<<SOMENAME>>_Roles"); } }
}