-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sqlite: Make AUTOINCREMENT accurate #22245
Conversation
@Pilchie for RC1 approval |
8c2fdc9
to
37e8fbf
Compare
Approved for RC1 (pending CI completion) |
Turns out SqlServer:Identity is also not first class. It is computed based on ValueGenerationStrategy and ValueGenerated flag. Aligned Sqlite to do the same to compute AutoIncrement only when applicable Resolves #10228
37e8fbf
to
e185c52
Compare
Hello @smitpatel! Because this pull request has the p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (
|
This is good, but I want to do more for #10228. In SqlServer, we have SqlServerValueGenerationStrategy.Identity and None you can use to turn on and off IDENTITY in the model. You currently can't turn off AUTOINCREMENT in the same way. |
I can add SqliteValueGenerationStrategy.AutoIncrement/None Also |
Side question, can you set a column as auto increment which is not int PK? |
No, it must be a non-composite integer primary key. |
So should there be an API, |
There are several ways the ValueGenerated.OnAdd could be satisifed on SQLite:
|
modelBuilder.Entity<MyEntity>().Property(e => e.Id).UseAutoincrement();
modelBuilder.Entity<MyOtherEntity>().Property(e => e.Id).UseAutoincrement(false);
|
At least that matches SQL Server. We might need a design meeting to discuss whether it should be on the property or primary key |
Needs-design? out of 5.0? Merge this (or leave this) and keep issue open to discuss design for next release? |
Merge this--it fixes a bug. Keep the issue open to iterate on later. I'll copy my notes into the issue. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think there was ever a functional bug here--just some extra clutter in the Migration. Migrations SQL generation wouldn't try to use the annotation unless it was on an integer primary key property
Turns out SqlServer:Identity is also not first class. It is computed based on ValueGenerationStrategy and ValueGenerated flag.
Aligned Sqlite to do the same to compute AutoIncrement only when applicable
Resolves #10228