Skip to content

Commit

Permalink
Fix scaffolding NRT issues
Browse files Browse the repository at this point in the history
That only surface in preview versions of VS.

Fixes dotnet#19496
  • Loading branch information
roji authored and svengeance committed Jan 15, 2020
1 parent d34b02c commit 3e8f4e2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace Microsoft.EntityFrameworkCore.Scaffolding.Metadata
/// </summary>
public class DatabasePrimaryKey : Annotatable
{
public DatabasePrimaryKey([NotNull] DatabaseTable table, [NotNull] string name)
public DatabasePrimaryKey([NotNull] DatabaseTable table, [CanBeNull] string? name)
{
Table = table;
Name = name;
Expand All @@ -29,7 +29,7 @@ public DatabasePrimaryKey([NotNull] DatabaseTable table, [NotNull] string name)
/// <summary>
/// The name of the primary key.
/// </summary>
public virtual string Name { get; [param: NotNull] set; }
public virtual string? Name { get; [param: CanBeNull] set; }

/// <summary>
/// The ordered list of columns that make up the primary key.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
using System.Diagnostics.CodeAnalysis;
using JB = JetBrains.Annotations;

#nullable enable

namespace Microsoft.EntityFrameworkCore.SqlServer.Scaffolding.Internal
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ UNION ALL
var tableColumnGroups = reader.Cast<DbDataRecord>()
.GroupBy(
ddr => (tableSchema: ddr.GetValueOrDefault<string>("table_schema"),
tableName: ddr.GetValueOrDefault<string>("table_name")));
tableName: ddr.GetFieldValue<string>("table_name")));

foreach (var tableColumnGroup in tableColumnGroups)
{
Expand Down Expand Up @@ -830,7 +830,7 @@ FROM [sys].[indexes] i
var tableIndexGroups = reader.Cast<DbDataRecord>()
.GroupBy(
ddr => (tableSchema: ddr.GetValueOrDefault<string>("table_schema"),
tableName: ddr.GetValueOrDefault<string>("table_name")));
tableName: ddr.GetFieldValue<string>("table_name")));

foreach (var tableIndexGroup in tableIndexGroups)
{
Expand Down Expand Up @@ -976,7 +976,7 @@ FROM [sys].[foreign_keys] AS [f]
var tableForeignKeyGroups = reader.Cast<DbDataRecord>()
.GroupBy(
ddr => (tableSchema: ddr.GetValueOrDefault<string>("table_schema"),
tableName: ddr.GetValueOrDefault<string>("table_name")));
tableName: ddr.GetFieldValue<string>("table_name")));

foreach (var tableForeignKeyGroup in tableForeignKeyGroups)
{
Expand All @@ -989,7 +989,7 @@ FROM [sys].[foreign_keys] AS [f]
.GroupBy(
c => (Name: c.GetValueOrDefault<string>("name"),
PrincipalTableSchema: c.GetValueOrDefault<string>("principal_table_schema"),
PrincipalTableName: c.GetValueOrDefault<string>("principal_table_name"),
PrincipalTableName: c.GetFieldValue<string>("principal_table_name"),
OnDeleteAction: c.GetValueOrDefault<string>("delete_referential_action_desc")));

foreach (var foreignKeyGroup in foreignKeyGroups)
Expand Down Expand Up @@ -1108,7 +1108,7 @@ 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)
Expand Down

0 comments on commit 3e8f4e2

Please sign in to comment.