In #30408 index options "DATA_COMPRESSION" is supported, I think there is another place where the same thing is needed. It's the primary key when creating a table for an entity.
Currently I create a custom class extends SqlServerAnnotationProvider to add annotation for data compression as following:
public class ExtendedSqlServerAnnotationProvider : SqlServerAnnotationProvider
{
public ExtendedSqlServerAnnotationProvider(RelationalAnnotationProviderDependencies dependencies) : base(dependencies)
{
}
public override IEnumerable<IAnnotation> For(IUniqueConstraint constraint, bool designTime)
{
foreach (var annotation in base.For(constraint, designTime))
{
yield return annotation;
}
if (!designTime)
{
yield break;
}
var key = constraint.MappedKeys.First();
var table = constraint.Table;
var dataCompression = key.GetDataCompression(StoreObjectIdentifier.Table(table.Name, table.Schema));
if(dataCompression.HasValue)
{
yield return new Annotation(SqlServerAnnotationNames.DataCompression, dataCompression.Value);
}
}
}
And then I extend SqlServerMigrationsSqlGenerator to build SQL for index options according to this annotation in AddPrimaryKeyOperation and AddUniqueConstraintOperation.
Finally I add extension methods xxx.UseDataCompression like the way index does.
In #30408 index options "DATA_COMPRESSION" is supported, I think there is another place where the same thing is needed. It's the primary key when creating a table for an entity.
Currently I create a custom class extends SqlServerAnnotationProvider to add annotation for data compression as following:
And then I extend SqlServerMigrationsSqlGenerator to build SQL for index options according to this annotation in AddPrimaryKeyOperation and AddUniqueConstraintOperation.
Finally I add extension methods xxx.UseDataCompression like the way index does.