/// <summary> /// Builds and returns the convention set for the current database provider. /// </summary> /// <returns> The convention set for the current database provider. </returns> public override ConventionSet CreateConventionSet() { var conventionSet = base.CreateConventionSet(); var valueGenerationStrategyConvention = new SqlServerValueGenerationStrategyConvention(Dependencies); conventionSet.ModelInitializedConventions.Add(valueGenerationStrategyConvention); conventionSet.ModelInitializedConventions.Add( new RelationalMaxIdentifierLengthConvention(128, Dependencies, RelationalDependencies)); ValueGeneratorConvention valueGeneratorConvention = new SqlServerValueGeneratorConvention(Dependencies, RelationalDependencies); ReplaceConvention(conventionSet.EntityTypeBaseTypeChangedConventions, valueGeneratorConvention); var sqlServerInMemoryTablesConvention = new SqlServerMemoryOptimizedTablesConvention(Dependencies); conventionSet.EntityTypeAnnotationChangedConventions.Add(sqlServerInMemoryTablesConvention); ReplaceConvention(conventionSet.EntityTypePrimaryKeyChangedConventions, valueGeneratorConvention); conventionSet.KeyAddedConventions.Add(sqlServerInMemoryTablesConvention); ReplaceConvention(conventionSet.ForeignKeyAddedConventions, valueGeneratorConvention); ReplaceConvention(conventionSet.ForeignKeyRemovedConventions, valueGeneratorConvention); var sqlServerIndexConvention = new SqlServerIndexConvention(Dependencies, _sqlGenerationHelper); conventionSet.EntityTypeBaseTypeChangedConventions.Add(sqlServerIndexConvention); ConventionSet.AddBefore( conventionSet.ModelFinalizedConventions, valueGenerationStrategyConvention, typeof(ValidatingConvention)); conventionSet.IndexAddedConventions.Add(sqlServerInMemoryTablesConvention); conventionSet.IndexAddedConventions.Add(sqlServerIndexConvention); conventionSet.IndexUniquenessChangedConventions.Add(sqlServerIndexConvention); conventionSet.IndexAnnotationChangedConventions.Add(sqlServerIndexConvention); conventionSet.PropertyNullabilityChangedConventions.Add(sqlServerIndexConvention); StoreGenerationConvention storeGenerationConvention = new SqlServerStoreGenerationConvention(Dependencies, RelationalDependencies); conventionSet.PropertyAnnotationChangedConventions.Add(sqlServerIndexConvention); ReplaceConvention(conventionSet.PropertyAnnotationChangedConventions, storeGenerationConvention); ReplaceConvention( conventionSet.PropertyAnnotationChangedConventions, (RelationalValueGeneratorConvention)valueGeneratorConvention); ReplaceConvention( conventionSet.ModelAnnotationChangedConventions, (RelationalDbFunctionConvention) new SqlServerDbFunctionConvention(Dependencies, RelationalDependencies)); ReplaceConvention(conventionSet.ModelFinalizedConventions, storeGenerationConvention); return(conventionSet); }
/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> public override ConventionSet AddConventions(ConventionSet conventionSet) { Check.NotNull(conventionSet, nameof(conventionSet)); base.AddConventions(conventionSet); var logger = Dependencies.Logger; var valueGenerationStrategyConvention = new SqlServerValueGenerationStrategyConvention(logger); conventionSet.ModelInitializedConventions.Add(valueGenerationStrategyConvention); conventionSet.ModelInitializedConventions.Add(new RelationalMaxIdentifierLengthConvention(128)); ValueGeneratorConvention valueGeneratorConvention = new SqlServerValueGeneratorConvention(logger); ReplaceConvention(conventionSet.BaseEntityTypeChangedConventions, valueGeneratorConvention); var sqlServerInMemoryTablesConvention = new SqlServerMemoryOptimizedTablesConvention(logger); conventionSet.EntityTypeAnnotationChangedConventions.Add(sqlServerInMemoryTablesConvention); ReplaceConvention(conventionSet.PrimaryKeyChangedConventions, valueGeneratorConvention); conventionSet.KeyAddedConventions.Add(sqlServerInMemoryTablesConvention); ReplaceConvention(conventionSet.ForeignKeyAddedConventions, valueGeneratorConvention); ReplaceConvention(conventionSet.ForeignKeyRemovedConventions, valueGeneratorConvention); var sqlServerIndexConvention = new SqlServerIndexConvention(_sqlGenerationHelper, logger); conventionSet.BaseEntityTypeChangedConventions.Add(sqlServerIndexConvention); conventionSet.ModelBuiltConventions.Add(valueGenerationStrategyConvention); conventionSet.IndexAddedConventions.Add(sqlServerInMemoryTablesConvention); conventionSet.IndexAddedConventions.Add(sqlServerIndexConvention); conventionSet.IndexUniquenessChangedConventions.Add(sqlServerIndexConvention); conventionSet.IndexAnnotationChangedConventions.Add(sqlServerIndexConvention); conventionSet.PropertyNullabilityChangedConventions.Add(sqlServerIndexConvention); conventionSet.PropertyAnnotationChangedConventions.Add(sqlServerIndexConvention); conventionSet.PropertyAnnotationChangedConventions.Add((SqlServerValueGeneratorConvention)valueGeneratorConvention); ReplaceConvention(conventionSet.ModelAnnotationChangedConventions, (RelationalDbFunctionConvention) new SqlServerDbFunctionConvention(logger)); return(conventionSet); }
public override ConventionSet AddConventions(ConventionSet conventionSet) { Check.NotNull(conventionSet, nameof(conventionSet)); base.AddConventions(conventionSet); var valueGenerationStrategyConvention = new SqlServerValueGenerationStrategyConvention(); conventionSet.ModelInitializedConventions.Add(valueGenerationStrategyConvention); ValueGeneratorConvention valueGeneratorConvention = new SqlServerValueGeneratorConvention(Dependencies.AnnotationProvider); ReplaceConvention(conventionSet.BaseEntityTypeSetConventions, valueGeneratorConvention); var sqlServerInMemoryTablesConvention = new SqlServerMemoryOptimizedTablesConvention(); conventionSet.EntityTypeAnnotationSetConventions.Add(sqlServerInMemoryTablesConvention); ReplaceConvention(conventionSet.PrimaryKeySetConventions, valueGeneratorConvention); conventionSet.KeyAddedConventions.Add(sqlServerInMemoryTablesConvention); ReplaceConvention(conventionSet.ForeignKeyAddedConventions, valueGeneratorConvention); ReplaceConvention(conventionSet.ForeignKeyRemovedConventions, valueGeneratorConvention); var sqlServerIndexConvention = new SqlServerIndexConvention(_sqlGenerationHelper); conventionSet.IndexAddedConventions.Add(sqlServerInMemoryTablesConvention); conventionSet.IndexAddedConventions.Add(sqlServerIndexConvention); conventionSet.IndexUniquenessConventions.Add(sqlServerIndexConvention); conventionSet.IndexAnnotationSetConventions.Add(sqlServerIndexConvention); conventionSet.PropertyNullableChangedConventions.Add(sqlServerIndexConvention); conventionSet.PropertyAnnotationSetConventions.Add(sqlServerIndexConvention); conventionSet.PropertyAnnotationSetConventions.Add((SqlServerValueGeneratorConvention)valueGeneratorConvention); return(conventionSet); }