Skip to content

Model (seed) data with newlines may result in SQL exceptions #23459

@starteNCS

Description

@starteNCS

After updating to net5.0 and therefore updating my efcore dependencies I run into an error when starting my tests.

The error Microsoft.Data.Sqlite.SqliteException : SQLite Error 1: 'Expression tree is too large (maximum depth 1000)'. is thrown and I cannot find any resources about the error in combination with efcore.

Here is the way we initalize the Db

services.AddScoped(p =>
            DbContextOptionsFactory<TContext>(
            p,
            (sp, options) => options
                .ConfigureWarnings(b => b.Log(CoreEventId.ManyServiceProvidersCreatedWarning))
                .UseLazyLoadingProxies()
                .UseSqlite(connection)));

And this chunk of code throws the error

ApplicationDbContext applicationDbContext =
                            scopedServices.GetRequiredService<ApplicationDbContext>();
var creator1 = (RelationalDatabaseCreator) applicationDbContext.Database
                            .GetService<IRelationalDatabaseCreator>();
creator1.CreateTables();
  Message: 
    Microsoft.Data.Sqlite.SqliteException : SQLite Error 1: 'Expression tree is too large (maximum depth 1000)'.
  Stack Trace: 
    SqliteException.ThrowExceptionForRC(Int32 rc, sqlite3 db)
    SqliteCommand.PrepareAndEnumerateStatements(Stopwatch timer)+MoveNext()
    SqliteCommand.GetStatements(Stopwatch timer)+MoveNext()
    SqliteDataReader.NextResult()
    SqliteCommand.ExecuteReader(CommandBehavior behavior)
    SqliteCommand.ExecuteReader()
    SqliteCommand.ExecuteNonQuery()
    RelationalCommand.ExecuteNonQuery(RelationalCommandParameterObject parameterObject)
    MigrationCommand.ExecuteNonQuery(IRelationalConnection connection, IReadOnlyDictionary`2 parameterValues)
    MigrationCommandExecutor.ExecuteNonQuery(IEnumerable`1 migrationCommands, IRelationalConnection connection)
    RelationalDatabaseCreator.CreateTables()
    TenantWebApplicationFactory`1.<ConfigureWebHost>b__2_0(IServiceCollection services) line 63
    <>c__DisplayClass10_0.<ConfigureServices>b__0(WebHostBuilderContext context, IServiceCollection services)
    <>c__DisplayClass11_0.<ConfigureServices>b__0(HostBuilderContext context, IServiceCollection builder)
    HostBuilder.CreateServiceProvider()
    HostBuilder.Build()
    WebApplicationFactory`1.CreateHost(IHostBuilder builder)
    DelegatedWebApplicationFactory.CreateHost(IHostBuilder builder)
    WebApplicationFactory`1.EnsureServer()
    WebApplicationFactory`1.CreateDefaultClient(DelegatingHandler[] handlers)
    WebApplicationFactory`1.CreateDefaultClient(Uri baseAddress, DelegatingHandler[] handlers)
    WebApplicationFactory`1.CreateClient(WebApplicationFactoryClientOptions options)
    WebApplicationFactory`1.CreateClient()
    <.ctor>b__9_0() line 30
    Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
    Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
    Lazy`1.CreateValue()
    Lazy`1.get_Value()
    TenantTestFixture.get_ServerClient() line 23
    TenantTestFixture.ctor() line 57

EF Core version: 5.0
Database provider: SQLite
Target framework: .NET 5.0
Operating system: Windows 10
IDE: Visual Studio 2019 16.8.1

Metadata

Metadata

Assignees

Type

No fields configured for Bug.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions