SQLite - Can't insert null into TIMESTAMP column

Open
#20,475 9 comments 7 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
csharp, sqlite
Domain
databases

Research direction

Start by reproducing the integration-test insert with the shown IsRequired, IsRowVersion, and IsConcurrencyToken configuration using Microsoft.Data.Sqlite 3.1.3 on netcoreapp3.1. Inspect whether the generated insert includes TxTimestamp and compare the SQLite behavior with the SQL Server-generated model. Done means identifying why the supplied byte value is not inserted, or documenting the provider limitation and available model override.

Written by the indexing model from the issue text.

Description

area-migrations area-sqlite customer-reported

Using in memory EF Core SQLite for integration tests. When creating an entity with the following column definition:

              entity.Property(e => e.TxTimestamp)
                    .IsRequired()
                    .IsRowVersion()
                    .IsConcurrencyToken();

Setting with

TxTimestamp = new byte[8] { 0, 1, 2, 3, 4, 5, 6, 7 }

I get the following error:

Microsoft.Data.Sqlite.SqliteException : SQLite Error 19: 'NOT NULL constraint failed: [TableName].TxTimestamp'.

Any ideas? It is like SQLite isn't inserting the value. Perhaps because with real SQL Server it wouldn't be able to? This model is generated from a SQL Server database and we are using database first, so I can't just change the model builder definition. (unless there is an easy way to override the one generated form the scaffold).

Additional context

Microsoft.Data.Sqlite version: 3.1.3
Target framework: netcoreapp3.1
Operating system: Win 10

Dominant language
C#
Stars
14.8k
Forks
3.4k
Avg merge
2d 5h
Merged PRs (30d)
134

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dotnet/efcore

All issues in dotnet/efcore

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.