src/Shared/EntityFramework/Migrations/Design/VisualBasicMigrationCodeGenerator.cs
/// <summary>
/// Generates code to specify the definition for a <see cref="ColumnModel" />.
/// </summary>
/// <param name="column"> The column definition to generate code for. </param>
/// <param name="writer"> Text writer to add the generated code to. </param>
/// <param name="emitName"> A value indicating whether to include the column name in the definition. </param>
Generates code to specify the definition for a .
Generates code to specify the definition for a .
[SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed")]
        [SuppressMessage("Microsoft.Globalization", "CA1308:NormalizeStringsToUppercase")]
        protected virtual void Generate(ColumnModel column, IndentedTextWriter writer, bool emitName = false)
        {
            Check.NotNull(column, "column");
            Check.NotNull(writer, "writer");
            writer.Write(" c.");
            writer.Write(TranslateColumnType(column.Type));
            writer.Write("(");
            var args = new List<string>();
            if (emitName)
            {
                args.Add("name := " + Quote(column.Name));
            }
            if (column.IsNullable == false)
            {
                args.Add("nullable := False");
            }
            if (column.MaxLength != null)
            {
                args.Add("maxLength := " + column.MaxLength);
            }
            if (column.Precision != null)
            {
                args.Add("precision := " + column.Precision);
            }
            if (column.Scale != null)
            {
                args.Add("scale := " + column.Scale);
            }
            if (column.IsFixedLength != null)
            {
                args.Add("fixedLength := " + column.IsFixedLength.ToString().ToLowerInvariant());
            }
            if (column.IsUnicode != null)
            {
                args.Add("unicode := " + column.IsUnicode.ToString().ToLowerInvariant());
            }
            if (column.IsIdentity)
            {
                args.Add("identity := True");
            }
            if (column.DefaultValue != null)
            {
#if NETSTANDARD
                args.Add("defaultValue := " + GenerateDefaultValueByType(column.DefaultValue));
#else
                args.Add("defaultValue := " + Generate((dynamic)column.DefaultValue));
#endif
            }
            if (!string.IsNullOrWhiteSpace(column.DefaultValueSql))
            {
                args.Add("defaultValueSql := " + Quote(column.DefaultValueSql));
            }
            if (column.IsTimestamp)
            {
                args.Add("timestamp := True");
            }
            if (!string.IsNullOrWhiteSpace(column.StoreType))
            {
                args.Add("storeType := " + Quote(column.StoreType));
            }
            writer.Write(args.Join());
            if (column.Annotations.Any())
            {
                writer.Indent++;
                writer.WriteLine(args.Any() ? "," : "");
                writer.Write("annotations := ");
                GenerateAnnotations(column.Annotations, writer);
                writer.Indent--;
            }
            writer.Write(")");
        }
[ SuppressMessage ( " " , " " ) ] [ SuppressMessage ( " " , " " ) ] protected virtual void Generate ( ColumnModel column , IndentedTextWriter writer , bool emitName = false ) { Check . NotNull ( column , " " ) ; Check . NotNull ( writer , " " ) ; writer . Write ( " " ) ; writer . Write ( TranslateColumnType ( column . Type ) ) ; writer . Write ( " " ) ; var args = new List < string > ( ) ; if ( emitName ) { args . Add ( " " + Quote ( column . Name ) ) ; } if ( column . IsNullable == false ) { args . Add ( " " ) ; } if ( column . MaxLength != null ) { args . Add ( " " + column . MaxLength ) ; } if ( column . Precision != null ) { args . Add ( " " + column . Precision ) ; } if ( column . Scale != null ) { args . Add ( " " + column . Scale ) ; } if ( column . IsFixedLength != null ) { args . Add ( " " + column . IsFixedLength . ToString ( ) . ToLowerInvariant ( ) ) ; } if ( column . IsUnicode != null ) { args . Add ( " " + column . IsUnicode . ToString ( ) . ToLowerInvariant ( ) ) ; } if ( column . IsIdentity ) { args . Add ( " " ) ; } if ( column . DefaultValue != null ) { if NETSTANDARD args . Add ( " " + GenerateDefaultValueByType ( column . DefaultValue ) ) ; else args . Add ( " " + Generate ( ( dynamic ) column . DefaultValue ) ) ; endif } if ( ! string . IsNullOrWhiteSpace ( column . DefaultValueSql ) ) { args . Add ( " " + Quote ( column . DefaultValueSql ) ) ; } if ( column . IsTimestamp ) { args . Add ( " " ) ; } if ( ! string . IsNullOrWhiteSpace ( column . StoreType ) ) { args . Add ( " " + Quote ( column . StoreType ) ) ; } writer . Write ( args . Join ( ) ) ; if ( column . Annotations . Any ( ) ) { writer . Indent ++ ; writer . WriteLine ( args . Any ( ) ? " " : " " ) ; writer . Write ( " " ) ; GenerateAnnotations ( column . Annotations , writer ) ; writer . Indent -- ; } writer . Write ( " " ) ; }
Generates code to specify the definition for a .
Generates code to specify the definition for a .
column
ColumnModel
The column definition to generate code for.
The column definition to generate code for .
writer
IndentedTextWriter
Text writer to add the generated code to.
Text writer to add the generated code to .
emitName
bool
A value indicating whether to include the column name in the definition.
A value indicating whether to include the column name in the definition .