Skip to content

ExecuteUpdateAsync throws SQLite Error 1: 'no such column: ...' when working with navigation properties in EFCore Sqlite #38010

@Rookian

Description

@Rookian

Bug description

When I run my tests with Sqlite adapter the code below fails with

SQLite Error 1: 'no such column: c.CompanyId'.

When I run it with Sql Server adapter everything works as expected.

Your code

// does not work with Sqlite, but with SQL Server
await db.CompanyItems
    .Where(x => x.Item == item && x.Company == company)
    .ExecuteUpdateAsync(x => x
            .SetProperty(i => i.BoolProp, false)
        cancellationToken);

// does not work with Sqlite, but with SQL Server
await db.CompanyItems
    .Where(x => x.Item.ID == item.Id && x.Company.Id == company.Id)
    .ExecuteUpdateAsync(x => x
            .SetProperty(i => i.BoolProp, false)
        cancellationToken);

// does work with Sqlite and SQL Server
await db.CompanyItems
    .Where(x => x.ItemId == item.Id && x.CompanyId == company.Id)
    .ExecuteUpdateAsync(x => x
            .SetProperty(i => i.BoolProp, false)
        cancellationToken);

Stack traces

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 System.Data.Common.DbCommand.ExecuteNonQueryAsync(CancellationToken cancellationToken)
--- End of stack trace from previous location ---
   at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.<ExecuteNonQueryAsync>d__18.MoveNext()
   at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.<ExecuteNonQueryAsync>d__18.MoveNext()
   at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.<ExecuteNonQueryAsync>d__18.MoveNext()

Verbose output


EF Core version

10.0.5

Database provider

No response

Target framework

.NET 10

Operating system

Windows 11

IDE

No response

Metadata

Metadata

Assignees

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions