You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: entity-framework/core/providers/sqlite/value-generation.md
+19-17Lines changed: 19 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,21 +15,22 @@ By convention, numeric primary key columns that are configured to have their val
15
15
16
16
### Configuring AUTOINCREMENT
17
17
18
-
Starting with EF Core 10, you can explicitly configure a property to use SQLite AUTOINCREMENT using the new Fluent API:
18
+
By convention, integer primary keys are automatically configured with AUTOINCREMENT when they don't have an explicitly assigned value. However, you may need to explicitly configure a property to use SQLite AUTOINCREMENT when the property has a value conversion from a non-integer type, or when overriding conventions:
By convention, integer primary keys are automatically configured with AUTOINCREMENT when they don't have an explicitly assigned value.
45
-
46
-
### Working with value converters
47
-
48
-
Starting with EF Core 10, SQLite AUTOINCREMENT works properly with value converters. Previously, properties with value converters weren't able to configure AUTOINCREMENT. For example:
In earlier versions of EF Core, this scenario would not work correctly and migrations would keep regenerating the same AlterColumn operation even without model changes.
53
-
54
45
## Disabling AUTOINCREMENT for default SQLite value generation
55
46
56
47
In some cases, you may want to disable AUTOINCREMENT and use SQLite's default value generation behavior instead. You can do this using the Metadata API:
This means that it's up to the application to supply a value for the property before saving to the database.
73
+
This means that it's up to the application to supply a value for the property before saving to the database. Note that this still won't disable the default value generation server-side, so non-EF usages could still get a generated value. To completely disable value generation the user can change the column type from `INTEGER` to `INT`.
Thanks to [@aradalvand](https://github.com/aradalvand) for proposing and pushing for this change (in [#32018](https://github.com/dotnet/efcore/issues/32018)).
630
630
631
+
<aname="sqlite"></a>
632
+
633
+
## SQLite
634
+
635
+
### Improved AUTOINCREMENT support
636
+
637
+
SQLite AUTOINCREMENT is now a first-class feature with full support through conventions and the Fluent API. Previously, properties with value converters couldn't configure AUTOINCREMENT and would cause false pending model change warnings.
0 commit comments