-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Add metadata/migration support for SQL Server full-text search catalog/index #37652
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
base: main
Are you sure you want to change the base?
Conversation
8243e26 to
b5ed266
Compare
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.
Pull request overview
This PR adds end-to-end SQL Server full-text search (FTS) metadata support to EF Core’s SQL Server provider, enabling configuration, scaffolding, and migration SQL generation for full-text catalogs and full-text indexes (including options like key index, catalog, change tracking, and per-column languages).
Changes:
- Introduces new full-text catalog metadata APIs (interfaces + builder) and full-text index builder APIs.
- Extends migrations/scaffolding/design-time code generation to persist and round-trip full-text catalogs and indexes.
- Adds functional/unit test coverage across model validation, annotation codegen, migrations, scaffolding, and compiled model behavior.
Reviewed changes
Copilot reviewed 37 out of 38 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| test/EFCore.SqlServer.Tests/Infrastructure/SqlServerModelValidatorTest.cs | Adds model validation tests for full-text index rules (duplicates, missing key index, invalid column types). |
| test/EFCore.SqlServer.Tests/Design/Internal/SqlServerAnnotationCodeGeneratorTest.cs | Verifies design-time fluent API generation for full-text index/catalog annotations. |
| test/EFCore.SqlServer.FunctionalTests/TestUtilities/SqlServerDatabaseCleaner.cs | Ensures test DB cleanup drops full-text catalogs. |
| test/EFCore.SqlServer.FunctionalTests/SqlServerApiConsistencyTest.cs | Registers new full-text catalog builder and metadata interfaces for API consistency testing. |
| test/EFCore.SqlServer.FunctionalTests/Scaffolding/SqlServerDatabaseModelFactoryTest.cs | Adds scaffolding tests for full-text catalogs and indexes. |
| test/EFCore.SqlServer.FunctionalTests/Scaffolding/CompiledModelSqlServerTest.cs | Adds compiled-model test ensuring full-text annotations aren’t emitted at runtime. |
| test/EFCore.SqlServer.FunctionalTests/Scaffolding/Baselines/Full_text_index/FullTextEntityUnsafeAccessors.cs | Adds compiled-model scaffolding baseline for full-text index scenario. |
| test/EFCore.SqlServer.FunctionalTests/Scaffolding/Baselines/Full_text_index/FullTextEntityEntityType.cs | Adds compiled-model scaffolding baseline entity-type metadata for full-text index scenario. |
| test/EFCore.SqlServer.FunctionalTests/Scaffolding/Baselines/Full_text_index/DbContextModelBuilder.cs | Adds compiled-model scaffolding baseline model builder output for full-text index scenario. |
| test/EFCore.SqlServer.FunctionalTests/Scaffolding/Baselines/Full_text_index/DbContextModel.cs | Adds compiled-model scaffolding baseline runtime model for full-text index scenario. |
| test/EFCore.SqlServer.FunctionalTests/Scaffolding/Baselines/Full_text_index/DbContextAssemblyAttributes.cs | Adds compiled-model scaffolding baseline assembly attributes for full-text index scenario. |
| test/EFCore.SqlServer.FunctionalTests/ModelBuilding/SqlServerTestModelBuilderExtensions.cs | Extends test model-builder abstraction to support full-text index/catalog configuration. |
| test/EFCore.SqlServer.FunctionalTests/ModelBuilding/SqlServerModelBuilderTestBase.cs | Adds model-building tests for full-text index/catalog fluent API configuration. |
| test/EFCore.SqlServer.FunctionalTests/Migrations/MigrationsSqlServerTest.cs | Adds migration tests for create/drop/alter full-text catalogs and create/drop full-text indexes + options. |
| src/EFCore.SqlServer/Scaffolding/Internal/SqlServerDatabaseModelFactory.cs | Scaffolds full-text catalogs and full-text indexes from SQL Server system catalogs. |
| src/EFCore.SqlServer/Properties/SqlServerStrings.resx | Adds new model validation error messages for full-text configuration. |
| src/EFCore.SqlServer/Properties/SqlServerStrings.Designer.cs | Adds strongly-typed accessors for new full-text validation messages. |
| src/EFCore.SqlServer/Migrations/SqlServerMigrationsSqlGenerator.cs | Generates SQL for creating/dropping full-text indexes and for create/drop/alter full-text catalogs. |
| src/EFCore.SqlServer/Migrations/Internal/SqlServerMigrationsAnnotationProvider.cs | Ensures drop operations carry full-text annotations so correct DROP FULLTEXT INDEX SQL is generated. |
| src/EFCore.SqlServer/Metadata/Internal/SqlServerFullTextCatalog.cs | Adds internal catalog metadata implementation stored in model annotations. |
| src/EFCore.SqlServer/Metadata/Internal/SqlServerAnnotationProvider.cs | Flows full-text catalog and index annotations into design-time annotations. |
| src/EFCore.SqlServer/Metadata/Internal/SqlServerAnnotationNames.cs | Adds annotation names for full-text index/catalog options. |
| src/EFCore.SqlServer/Metadata/ISqlServerFullTextCatalog.cs | Adds public metadata interface for full-text catalogs (runtime model view). |
| src/EFCore.SqlServer/Metadata/IReadOnlySqlServerFullTextCatalog.cs | Adds public read-only metadata interface for full-text catalogs. |
| src/EFCore.SqlServer/Metadata/IMutableSqlServerFullTextCatalog.cs | Adds public mutable metadata interface for full-text catalogs. |
| src/EFCore.SqlServer/Metadata/IConventionSqlServerFullTextCatalog.cs | Adds public convention metadata interface for full-text catalogs. |
| src/EFCore.SqlServer/Metadata/Builders/SqlServerFullTextIndexBuilder`1.cs | Adds generic full-text index builder API surface. |
| src/EFCore.SqlServer/Metadata/Builders/SqlServerFullTextIndexBuilder.cs | Adds non-generic full-text index builder API surface. |
| src/EFCore.SqlServer/Metadata/Builders/SqlServerFullTextCatalogBuilder.cs | Adds full-text catalog builder API surface. |
| src/EFCore.SqlServer/Infrastructure/Internal/SqlServerModelValidator.cs | Adds model validation for full-text index constraints (single per table, key index required, column-type checks). |
| src/EFCore.SqlServer/FullTextChangeTracking.cs | Adds enum representing SQL Server full-text change tracking modes. |
| src/EFCore.SqlServer/Extensions/SqlServerModelExtensions.cs | Adds model-level extension methods to add/find/remove/enumerate full-text catalogs. |
| src/EFCore.SqlServer/Extensions/SqlServerModelBuilderExtensions.cs | Adds HasFullTextCatalog fluent API on ModelBuilder. |
| src/EFCore.SqlServer/Extensions/SqlServerIndexExtensions.cs | Adds index-level extension methods for full-text index annotations (key index, catalog, change tracking, languages). |
| src/EFCore.SqlServer/Extensions/SqlServerIndexBuilderExtensions.cs | Adds fluent API extensions for full-text index options on IndexBuilder. |
| src/EFCore.SqlServer/Extensions/SqlServerEntityTypeBuilderExtensions.cs | Adds HasFullTextIndex fluent API on EntityTypeBuilder (generic and non-generic). |
| src/EFCore.SqlServer/Design/Internal/SqlServerCSharpRuntimeAnnotationCodeGenerator.cs | Prevents full-text annotations from being serialized into runtime/compiled models. |
| src/EFCore.SqlServer/Design/Internal/SqlServerAnnotationCodeGenerator.cs | Adds design-time fluent API generation for full-text catalogs and full-text index options. |
Files not reviewed (1)
- src/EFCore.SqlServer/Properties/SqlServerStrings.Designer.cs: Language not supported
ab4af11 to
60109d6
Compare
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.
Pull request overview
Copilot reviewed 37 out of 38 changed files in this pull request and generated 1 comment.
Files not reviewed (1)
- src/EFCore.SqlServer/Properties/SqlServerStrings.Designer.cs: Language not supported
60109d6 to
45e68d5
Compare
| // FullTextCatalogs is placed on the relational model by the annotation provider, | ||
| // but is also available on IModel - remove it to avoid serialization issues. | ||
| parameters.Annotations.Remove(SqlServerAnnotationNames.FullTextCatalogs); |
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.
Why is FullTextCatalogs placed on the relational model by the annotation provider?
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.
Copilot says:
FullTextCatalogs are placed on the relational model so that the MigrationsModelDiffer can detect
catalog changes and generate AlterDatabaseOperation.
Is this incorrect? If so let me know how you want it.
test/EFCore.SqlServer.FunctionalTests/SqlServerApiConsistencyTest.cs
Outdated
Show resolved
Hide resolved
test/EFCore.SqlServer.FunctionalTests/ModelBuilding/SqlServerTestModelBuilderExtensions.cs
Outdated
Show resolved
Hide resolved
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.
Pull request overview
Copilot reviewed 37 out of 38 changed files in this pull request and generated 3 comments.
Files not reviewed (1)
- src/EFCore.SqlServer/Properties/SqlServerStrings.Designer.cs: Language not supported
src/EFCore.SqlServer/Migrations/SqlServerMigrationsSqlGenerator.cs
Outdated
Show resolved
Hide resolved
| var isDefault = reader.GetFieldValue<bool>("is_default"); | ||
| var isAccentSensitive = reader.GetFieldValue<bool>("is_accent_sensitivity_on"); | ||
|
|
||
| var catalog = new SqlServerFullTextCatalog(name, model: null!, ConfigurationSource.DataAnnotation); |
Copilot
AI
Feb 11, 2026
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.
SqlServerFullTextCatalog is constructed with model: null! during scaffolding. While this currently works because the Model property isn't dereferenced during scaffolding (only used in the IsReadOnly check which safely handles null), this is fragile. If future code attempts to access the Model property directly, it will throw NullReferenceException. Consider using a sentinel pattern or making Model nullable in the constructor.
3583f0a to
bb2baf5
Compare
Closes #11488