/// <summary> /// Configures the database sequence used for the hi-lo pattern to generate values for key properties /// marked as <see cref="ValueGenerated.OnAdd" />, when targeting SQL Server. /// </summary> /// <param name="modelBuilder"> The model builder. </param> /// <param name="name"> The name of the sequence. </param> /// <param name="schema">The schema of the sequence. </param> /// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param> /// <returns> A builder to further configure the sequence. </returns> public static IConventionSequenceBuilder HasHiLoSequence( [NotNull] this IConventionModelBuilder modelBuilder, [CanBeNull] string name, [CanBeNull] string schema, bool fromDataAnnotation = false) { if (!modelBuilder.CanSetHiLoSequence(name, schema)) { return(null); } modelBuilder.Metadata.SetHiLoSequenceName(name, fromDataAnnotation); modelBuilder.Metadata.SetHiLoSequenceSchema(schema, fromDataAnnotation); return(name == null ? null : modelBuilder.HasSequence(name, schema, fromDataAnnotation)); }
/// <summary> /// Configures the database sequence used for the hi-lo pattern to generate values for key properties /// marked as <see cref="ValueGenerated.OnAdd" />, when targeting PostgreSQL. /// </summary> /// <param name="modelBuilder"> The model builder. </param> /// <param name="name"> The name of the sequence. </param> /// <param name="schema">The schema of the sequence. </param> /// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param> /// <returns> A builder to further configure the sequence. </returns> public static IConventionSequenceBuilder?HasHiLoSequence( this IConventionModelBuilder modelBuilder, string?name, string?schema, bool fromDataAnnotation = false) { if (!modelBuilder.CanSetHiLoSequence(name, schema)) { return(null); } modelBuilder.Metadata.SetHiLoSequenceName(name, fromDataAnnotation); modelBuilder.Metadata.SetHiLoSequenceSchema(schema, fromDataAnnotation); return(name is null ? null : modelBuilder.HasSequence(name, schema, fromDataAnnotation)); }