protected override ConventionSet CreateConventionSet() { var conventions = base.CreateConventionSet(); var sqlServerValueGenerationStrategyConvention = new SqlServerValueGenerationStrategyConvention(); conventions.KeyAddedConventions.Add(sqlServerValueGenerationStrategyConvention); conventions.ForeignKeyAddedConventions.Add(sqlServerValueGenerationStrategyConvention); conventions.ForeignKeyRemovedConventions.Add(sqlServerValueGenerationStrategyConvention); conventions.ModelConventions.Add(sqlServerValueGenerationStrategyConvention); return(conventions); }
private static InternalModelBuilder createInternalModelBuilder() { var conventions = new ConventionSet(); conventions.EntityTypeAddedConventions.Add(new PropertyDiscoveryConvention()); conventions.EntityTypeAddedConventions.Add(new KeyDiscoveryConvention()); var keyConvention = new KeyConvention(); conventions.KeyAddedConventions.Add(keyConvention); conventions.ForeignKeyRemovedConventions.Add(keyConvention); var sqlServerValueGenerationStrategyConvention = new SqlServerValueGenerationStrategyConvention(); conventions.ForeignKeyAddedConventions.Add(sqlServerValueGenerationStrategyConvention); conventions.ForeignKeyRemovedConventions.Add(sqlServerValueGenerationStrategyConvention); return(new InternalModelBuilder(new Model(), conventions)); }
/// <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); var sqlServerIndexConvention = new SqlServerIndexConvention(Dependencies, RelationalDependencies, _sqlGenerationHelper); ReplaceConvention(conventionSet.EntityTypeBaseTypeChangedConventions, valueGenerationConvention); conventionSet.EntityTypeBaseTypeChangedConventions.Add(sqlServerIndexConvention); var sqlServerInMemoryTablesConvention = new SqlServerMemoryOptimizedTablesConvention(Dependencies, RelationalDependencies); conventionSet.EntityTypeAnnotationChangedConventions.Add(sqlServerInMemoryTablesConvention); ReplaceConvention( conventionSet.ForeignKeyPropertiesChangedConventions, (RelationalValueGenerationConvention)valueGenerationConvention); ReplaceConvention( conventionSet.ForeignKeyOwnershipChangedConventions, (RelationalValueGenerationConvention)valueGenerationConvention); ReplaceConvention( conventionSet.EntityTypeAnnotationChangedConventions, (RelationalValueGenerationConvention)valueGenerationConvention); var sqlServerTemporalConvention = new SqlServerTemporalConvention(Dependencies, RelationalDependencies); ConventionSet.AddBefore( conventionSet.EntityTypeAnnotationChangedConventions, sqlServerTemporalConvention, typeof(SqlServerValueGenerationConvention)); ReplaceConvention(conventionSet.EntityTypePrimaryKeyChangedConventions, valueGenerationConvention); conventionSet.KeyAddedConventions.Add(sqlServerInMemoryTablesConvention); var sqlServerOnDeleteConvention = new SqlServerOnDeleteConvention(Dependencies, RelationalDependencies); ReplaceConvention(conventionSet.ForeignKeyAddedConventions, valueGenerationConvention); ReplaceConvention(conventionSet.ForeignKeyAddedConventions, (CascadeDeleteConvention)sqlServerOnDeleteConvention); ReplaceConvention(conventionSet.ForeignKeyRemovedConventions, valueGenerationConvention); ReplaceConvention(conventionSet.ForeignKeyRequirednessChangedConventions, (CascadeDeleteConvention)sqlServerOnDeleteConvention); conventionSet.SkipNavigationForeignKeyChangedConventions.Add(sqlServerOnDeleteConvention); 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); conventionSet.ModelFinalizingConventions.Add(valueGenerationStrategyConvention); ReplaceConvention(conventionSet.ModelFinalizingConventions, storeGenerationConvention); ReplaceConvention( conventionSet.ModelFinalizingConventions, (SharedTableConvention) new SqlServerSharedTableConvention(Dependencies, RelationalDependencies)); conventionSet.ModelFinalizingConventions.Add(new SqlServerDbFunctionConvention(Dependencies, RelationalDependencies)); ReplaceConvention( conventionSet.ModelFinalizedConventions, (RuntimeModelConvention) new SqlServerRuntimeModelConvention(Dependencies, RelationalDependencies)); conventionSet.SkipNavigationForeignKeyChangedConventions.Add(sqlServerTemporalConvention); return(conventionSet); }