Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Sep 26, 2025

  • Create SQLite value generation documentation file
  • Document SQLite AUTOINCREMENT configuration using Fluent API and annotations
  • Add code examples showing how to configure AUTOINCREMENT
  • Document how to use Metadata API to set strategy to None for default SQLite value generation
  • Update SQLite provider index to reference the new value generation documentation
  • Create working sample code files that compile successfully
  • Test markdown formatting and links
  • Validate documentation follows EF documentation patterns
  • Address feedback: Remove value converters section from docs, add to EF 10 what's new
  • Update documentation to explain when UseAutoincrement() API is useful
  • Add note about ValueGeneratedNever() not disabling server-side generation
  • Remove Program.cs file
  • Update samples to use proper APIs (mix of current annotation approach and future Fluent API)
  • Add SQLite AUTOINCREMENT note to EF 10 what's new documentation
  • Update to EF 10 RC version (10.0.0-rc.1.25451.107) and target net10.0
  • Add samples/global.json specifying .NET 10 SDK version
  • Use new UseAutoincrement() and SetValueGenerationStrategy APIs in samples
  • Add reference to core/providers/sqlite/value-generation from TOC
  • Clean up documentation: remove additional resources, update convention text, streamline content
  • Final cleanup: add link to docs, remove unused file, make types public

Key Changes Made:

  • Added link from EF 10 what's new documentation to the new SQLite value generation docs page
  • Removed unused SqliteAutoincrement.cs sample file that was not referenced anywhere
  • Made context classes public in remaining sample files (SqliteAutoincrementWithValueConverterContext and SqliteValueGenerationStrategyNoneContext)
  • Maintained consistent public access for entity types and value types
  • Ensured all sample code follows proper visibility patterns for documentation examples
Original prompt

This section details on the original issue you should resolve

<issue_title>Update Sqlite Autoincrement docs</issue_title>
<issue_description>See dotnet/efcore#36717</issue_description>

<agent_instructions>Make sure to include a code snippet of how to configure it. Also show how to use the Metadata API to set the strategy to None to get the default Sqlite value generation.</agent_instructions>

Comments on the Issue (you are @copilot in this section)

Fixes #5101

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@Copilot Copilot AI changed the title [WIP] Update Sqlite Autoincrement docs Update SQLite AUTOINCREMENT documentation for EF Core 10 Sep 26, 2025
Copilot finished work on behalf of AndriySvyryd September 26, 2025 20:26
@Copilot Copilot AI requested a review from AndriySvyryd September 26, 2025 20:26
}
```

This means that it's up to the application to supply a value for the property before saving to the database.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Add a sentence saying 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a sentence explaining that ValueGeneratedNever() still won't disable the default value generation server-side, so non-EF usages could still get a generated value. Also mentioned that to completely disable value generation the user can change the column type from INTEGER to INT. Commit: 055ab79

{
modelBuilder.Entity<Post>()
.Property(p => p.Id)
.HasAnnotation("Sqlite:ValueGenerationStrategy", "None");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot

Suggested change
.HasAnnotation("Sqlite:ValueGenerationStrategy", "None");
.Metadata.SetValueGenerationStrategy(SqliteValueGenerationStrategy.None);

@@ -0,0 +1,2 @@
// This file is for documentation samples only.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Remove this file

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the Program.cs file as requested. Commit: 055ab79

</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.0" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Reference 10.0.0-rc.1.25451.107 version, target net10.0, add samples/global.json specifying .NET 10 SDK version 10.0.100-rc.1.25451.107

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Do this and the other requested changes without verifying that it builds correctly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to reference EF 10 RC version (10.0.0-rc.1.25451.107), target net10.0, added samples/global.json specifying .NET 10 SDK version (10.0.100-rc.1.25451.107), and updated all samples to use the new UseAutoincrement() and SetValueGenerationStrategy APIs as requested. Commit: [short hash will be provided after commit]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to reference EF 10 RC version (10.0.0-rc.1.25451.107), target net10.0, added samples/global.json specifying .NET 10 SDK version (10.0.100-rc.1.25451.107), and updated all samples to use the new UseAutoincrement() and SetValueGenerationStrategy APIs as requested without build verification. Commit: 7c1aa86

modelBuilder.Entity<BlogPost>()
.Property(b => b.Id)
.HasConversion<int>()
.HasAnnotation("Sqlite:Autoincrement", true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Use the new API here and other places

Copy link
Contributor Author

Copilot AI commented Sep 29, 2025

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • 5rqvsblobprodcus385.vsblob.vsassets.io
    • Triggering command: dotnet build (dns block)
  • m16vsblobprodcus374.vsblob.vsassets.io
    • Triggering command: dotnet build (dns block)
  • s8mvsblobprodcus38.vsblob.vsassets.io
    • Triggering command: dotnet build (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot finished work on behalf of AndriySvyryd September 29, 2025 19:51
@AndriySvyryd
Copy link
Member

@copilot Add a reference to core/providers/sqlite/value-generation from TOC

Comment on lines 37 to 40

## Additional Resources

* [SQLite Value Generation](xref:core/providers/sqlite/value-generation) - Information about SQLite AUTOINCREMENT and value generation patterns.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Remove this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the "Additional Resources" section from the SQLite provider index page. Commit: c00dee1


### Configuring AUTOINCREMENT

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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot

Suggested change
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 are not composite and don't have a foreign key on them. 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:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the convention text to clarify that AUTOINCREMENT applies to non-composite primary keys without foreign keys. Commit: c00dee1

});
```

This ensures that the AUTOINCREMENT feature is properly applied when the migration is executed against the SQLite database. No newline at end of file
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Files should end with a single newline character

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed the file ending to have a single newline character. Commit: c00dee1

Copy link
Contributor Author

Copilot AI commented Sep 29, 2025

@copilot Add a reference to core/providers/sqlite/value-generation from TOC

Added reference to core/providers/sqlite/value-generation from the main TOC under the SQLite provider section. Commit: [short hash will be provided after commit]

@copilot Add a reference to core/providers/sqlite/value-generation from TOC

Added reference to core/providers/sqlite/value-generation from the main TOC under the SQLite provider section. The new documentation is now accessible through the navigation menu. Commit: eba15dc

Comment on lines 22 to 43
Starting with EF Core 10, you can also use the new Fluent API:

```csharp
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<BlogPost>()
.Property(b => b.Id)
.HasConversion<int>()
.UseAutoincrement();
}
```

This is equivalent to using the more general value generation API:

```csharp
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Blog>()
.Property(b => b.Id)
.ValueGeneratedOnAdd();
}
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Remove this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the redundant Fluent API example section from the value generation documentation. Commit: c00dee1

@Copilot Copilot AI requested a review from AndriySvyryd September 29, 2025 20:04
Copilot finished work on behalf of AndriySvyryd September 29, 2025 20:04

### Improved AUTOINCREMENT support

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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Add a link to the new docs page

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a link to the new SQLite value generation documentation page in the EF 10 what's new section. Commit: 1440b77

@@ -0,0 +1,26 @@
using Microsoft.EntityFrameworkCore;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Remove this file, it's not referenced from anywhere

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the SqliteAutoincrement.cs file since it was not referenced anywhere in the documentation. Commit: 1440b77

public static implicit operator BlogId(int value) => new(value);
}

internal class SqliteAutoincrementWithValueConverterContext : DbContext
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Make this and the other added types public

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made the context classes public in SqliteAutoincrementWithValueConverter.cs and SqliteValueGenerationStrategyNone.cs. Commit: 1440b77

…ion text, remove fluent API section, fix file ending

Co-authored-by: AndriySvyryd <[email protected]>
@AndriySvyryd
Copy link
Member

@copilot Replace the PR description with a nicely formatted summary

…e file, make context classes public

Co-authored-by: AndriySvyryd <[email protected]>
@AndriySvyryd AndriySvyryd marked this pull request as ready for review September 29, 2025 20:11
Copy link
Contributor Author

Copilot AI commented Sep 29, 2025

@copilot Replace the PR description with a nicely formatted summary

I don't have the ability to directly modify PR descriptions through my available tools. The PR description would need to be updated through the GitHub web interface or using GitHub API access. I can provide you with a nicely formatted summary that you could copy and paste to replace the current description if that would be helpful.

@Copilot Copilot AI requested a review from AndriySvyryd September 29, 2025 20:13
Copilot finished work on behalf of AndriySvyryd September 29, 2025 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update Sqlite Autoincrement docs
3 participants