Open Closed

"SaasEditions" already exists error for multiple dbContext in EntityFrameworkCoreTestModule #4567


User avatar
0
ademaygun created
  • ABP Framework version: v5.3.3
  • UI type: Angular
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): no
  • Exception message and stack trace:
SQLite Error 1: 'table "SaasEditions" already exists'.
  at Microsoft.Data.Sqlite.SqliteException.ThrowExceptionForRC(Int32 rc, sqlite3 db)
   at Microsoft.Data.Sqlite.SqliteCommand.<PrepareAndEnumerateStatements>d__64.MoveNext()
   at Microsoft.Data.Sqlite.SqliteCommand.<GetStatements>d__54.MoveNext()
   at Microsoft.Data.Sqlite.SqliteDataReader.NextResult()
   at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader(CommandBehavior behavior)
   at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader()
   at Microsoft.Data.Sqlite.SqliteCommand.ExecuteNonQuery()
   at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteNonQuery(RelationalCommandParameterObject parameterObject)
   at Microsoft.EntityFrameworkCore.Migrations.MigrationCommand.ExecuteNonQuery(IRelationalConnection connection, IReadOnlyDictionary`2 parameterValues)
   at Microsoft.EntityFrameworkCore.Migrations.Internal.MigrationCommandExecutor.ExecuteNonQuery(IEnumerable`1 migrationCommands, IRelationalConnection connection)
   at Microsoft.EntityFrameworkCore.Storage.RelationalDatabaseCreator.CreateTables()
   at MyCompany.ABC.EntityFrameworkCore.ABCEntityFrameworkCoreTestModule.CreateDatabaseAndGetConnection() in
  • Steps to reproduce the issue:"
  • Create a new DbContext and move ConfigureSaas() in second dbcontext

I have two Dbcontext and run without error. But I cannot run test. and I got error : Microsoft.Data.Sqlite.SqliteException: 'SQLite Error 1: 'table "SaasEditions" already exists

public class MyFirsDbContext :  AbpDbContext<MyFirsDbContext>,IHasEventInbox, IHasEventOutbox, IServicePriceDbContext
//IIdentityProDbContext,
//ISaasDbContext
{

}
[ReplaceDbContext(typeof(IIdentityProDbContext))]
[ReplaceDbContext(typeof(ISaasDbContext))]
[ConnectionStringName("Second")]
public class MySecondDbContext :AbpDbContext<MySecondDbContext>, IIdentityProDbContext, ISaasDbContext
{
 ...
    // SaaS
    public DbSet<Tenant> Tenants { get; set; }
    public DbSet<Edition> Editions { get; set; }
 ...
}


2 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    I can't reproduce the problem, could you provide the full steps to reproduce? thanks.

  • User Avatar
    0
    ademaygun created

    My fault. builder.ConfigureSaas() method was being wrongly called at FirstEfCoreEntityExtensionMappings.cs. I noticed while trying to reproduce the steps. Many thank.

Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
Do you need assistance from an ABP expert?
Schedule a Meeting
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v9.3.0-preview. Updated on April 16, 2025, 12:13