/// <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, RelationalDependencies); conventionSet.ModelInitializedConventions.Add(valueGenerationStrategyConvention); conventionSet.ModelInitializedConventions.Add( new RelationalMaxIdentifierLengthConvention(128, Dependencies, RelationalDependencies)); ValueGenerationConvention valueGenerationConvention = new SqlServerValueGenerationConvention(Dependencies, RelationalDependencies); ReplaceConvention(conventionSet.EntityTypeBaseTypeChangedConventions, valueGenerationConvention); var sqlServerInMemoryTablesConvention = new SqlServerMemoryOptimizedTablesConvention(Dependencies, RelationalDependencies); conventionSet.EntityTypeAnnotationChangedConventions.Add(sqlServerInMemoryTablesConvention); ReplaceConvention(conventionSet.EntityTypePrimaryKeyChangedConventions, valueGenerationConvention); conventionSet.KeyAddedConventions.Add(sqlServerInMemoryTablesConvention); ReplaceConvention(conventionSet.ForeignKeyAddedConventions, valueGenerationConvention); ReplaceConvention(conventionSet.ForeignKeyRemovedConventions, valueGenerationConvention); var sqlServerIndexConvention = new SqlServerIndexConvention(Dependencies, RelationalDependencies, _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, (RelationalValueGenerationConvention)valueGenerationConvention); ReplaceConvention( conventionSet.ModelAnnotationChangedConventions, (RelationalDbFunctionConvention) new SqlServerDbFunctionConvention(Dependencies, RelationalDependencies)); ReplaceConvention(conventionSet.ModelFinalizedConventions, storeGenerationConvention); return(conventionSet); }
/// <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 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); StoreGenerationConvention storeGenerationConvention = new SqlServerStoreGenerationConvention(); conventionSet.PropertyAnnotationChangedConventions.Add(sqlServerIndexConvention); ReplaceConvention(conventionSet.PropertyAnnotationChangedConventions, storeGenerationConvention); ReplaceConvention( conventionSet.PropertyAnnotationChangedConventions, (RelationalValueGeneratorConvention)valueGeneratorConvention); ReplaceConvention( conventionSet.ModelAnnotationChangedConventions, (RelationalDbFunctionConvention) new SqlServerDbFunctionConvention(logger)); ReplaceConvention(conventionSet.ModelBuiltConventions, storeGenerationConvention); return(conventionSet); }