diff --git a/src/EFCore.Relational/Scaffolding/Metadata/DatabaseForeignKey.cs b/src/EFCore.Relational/Scaffolding/Metadata/DatabaseForeignKey.cs index b749ce1f7e9..ba179c5c09a 100644 --- a/src/EFCore.Relational/Scaffolding/Metadata/DatabaseForeignKey.cs +++ b/src/EFCore.Relational/Scaffolding/Metadata/DatabaseForeignKey.cs @@ -17,7 +17,7 @@ public class DatabaseForeignKey : Annotatable { public DatabaseForeignKey( [NotNull] DatabaseTable table, - [NotNull] string name, + [CanBeNull] string? name, [NotNull] DatabaseTable principalTable) { Table = table; @@ -51,7 +51,7 @@ public DatabaseForeignKey( /// /// The foreign key constraint name. /// - public virtual string Name { get; [param: NotNull] set; } + public virtual string? Name { get; [param: CanBeNull] set; } /// /// The action performed by the database when a row constrained by this foreign key diff --git a/src/EFCore.Relational/Scaffolding/Metadata/DatabaseIndex.cs b/src/EFCore.Relational/Scaffolding/Metadata/DatabaseIndex.cs index d1c2ef278a4..7211a25dd4c 100644 --- a/src/EFCore.Relational/Scaffolding/Metadata/DatabaseIndex.cs +++ b/src/EFCore.Relational/Scaffolding/Metadata/DatabaseIndex.cs @@ -14,7 +14,7 @@ namespace Microsoft.EntityFrameworkCore.Scaffolding.Metadata /// public class DatabaseIndex : Annotatable { - public DatabaseIndex([NotNull] DatabaseTable table, [NotNull] string name) + public DatabaseIndex([NotNull] DatabaseTable table, [CanBeNull] string? name) { Table = table; Name = name; @@ -29,7 +29,7 @@ public DatabaseIndex([NotNull] DatabaseTable table, [NotNull] string name) /// /// The index name. /// - public virtual string Name { get; [param: NotNull] set; } + public virtual string? Name { get; [param: CanBeNull] set; } /// /// The ordered list of columns that make up the index. diff --git a/src/EFCore.Relational/Scaffolding/Metadata/DatabaseUniqueConstraint.cs b/src/EFCore.Relational/Scaffolding/Metadata/DatabaseUniqueConstraint.cs index 6dac16ac7ec..aa91f333b10 100644 --- a/src/EFCore.Relational/Scaffolding/Metadata/DatabaseUniqueConstraint.cs +++ b/src/EFCore.Relational/Scaffolding/Metadata/DatabaseUniqueConstraint.cs @@ -14,7 +14,7 @@ namespace Microsoft.EntityFrameworkCore.Scaffolding.Metadata /// public class DatabaseUniqueConstraint : Annotatable { - public DatabaseUniqueConstraint([NotNull] DatabaseTable table, [NotNull] string name) + public DatabaseUniqueConstraint([NotNull] DatabaseTable table, [CanBeNull] string? name) { Table = table; Name = name; @@ -29,7 +29,7 @@ public DatabaseUniqueConstraint([NotNull] DatabaseTable table, [NotNull] string /// /// The name of the constraint. /// - public virtual string Name { get; [param: NotNull] set; } + public virtual string? Name { get; [param: CanBeNull] set; } /// /// The ordered list of columns that make up the constraint. diff --git a/src/EFCore.SqlServer/Scaffolding/Internal/SqlDataReaderExtension.cs b/src/EFCore.SqlServer/Scaffolding/Internal/SqlDataReaderExtension.cs index d497bf8ff00..f62c06a2364 100644 --- a/src/EFCore.SqlServer/Scaffolding/Internal/SqlDataReaderExtension.cs +++ b/src/EFCore.SqlServer/Scaffolding/Internal/SqlDataReaderExtension.cs @@ -5,8 +5,6 @@ using System.Diagnostics.CodeAnalysis; using JB = JetBrains.Annotations; -#nullable enable - namespace Microsoft.EntityFrameworkCore.SqlServer.Scaffolding.Internal { /// diff --git a/src/EFCore.SqlServer/Scaffolding/Internal/SqlServerDatabaseModelFactory.cs b/src/EFCore.SqlServer/Scaffolding/Internal/SqlServerDatabaseModelFactory.cs index c2a3ee262b5..633f8ba26ae 100644 --- a/src/EFCore.SqlServer/Scaffolding/Internal/SqlServerDatabaseModelFactory.cs +++ b/src/EFCore.SqlServer/Scaffolding/Internal/SqlServerDatabaseModelFactory.cs @@ -1108,10 +1108,10 @@ FROM sys.databases return result != null ? Convert.ToByte(result) : (byte)0; } - private static string DisplayName(string? schema, string name) + private static string DisplayName(string? schema, string? name) => (!string.IsNullOrEmpty(schema) ? schema + "." : "") + name; - private static ReferentialAction? ConvertToReferentialAction(string onDeleteAction) + private static ReferentialAction? ConvertToReferentialAction(string? onDeleteAction) { switch (onDeleteAction) {