Skip to content

Commit

Permalink
Add quirk mode for #23092
Browse files Browse the repository at this point in the history
  • Loading branch information
AndriySvyryd committed Oct 29, 2020
1 parent d410f55 commit 00a9a72
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
Expand Down Expand Up @@ -201,12 +202,14 @@ private List<string> GetNullableColumns(IIndex index)
return null;
}

var useOldBehavior = AppContext.TryGetSwitch("Microsoft.EntityFrameworkCore.Issue23092_2", out var isEnabled) && isEnabled;
var nullableColumns = new List<string>();
var table = StoreObjectIdentifier.Table(tableName, index.DeclaringEntityType.GetSchema());
foreach (var property in index.Properties)
{
var columnName = property.GetColumnName(table);
if (columnName == null)
if (columnName == null
&& !useOldBehavior)
{
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,15 @@ private IConventionForeignKeyBuilder DiscoverProperties(
IConventionForeignKeyBuilder relationshipBuilder,
IConventionContext context)
{
var useOldBehavior = AppContext.TryGetSwitch("Microsoft.EntityFrameworkCore.Issue23092_1", out var isEnabled) && isEnabled;

var foreignKey = relationshipBuilder.Metadata;
var foreignKeyProperties = FindCandidateForeignKeyProperties(relationshipBuilder.Metadata, onDependent: true);
var propertiesConfigurationSource = foreignKey.GetPropertiesConfigurationSource();
if (!ConfigurationSource.Convention.OverridesStrictly(propertiesConfigurationSource)
&& (propertiesConfigurationSource != ConfigurationSource.Convention
|| (foreignKey.Properties.All(p => !p.IsImplicitlyCreated())
|| (!useOldBehavior
&& foreignKey.Properties.All(p => !p.IsImplicitlyCreated())
&& (foreignKeyProperties == null
|| !foreignKey.Properties.SequenceEqual(foreignKeyProperties)))))
{
Expand Down

0 comments on commit 00a9a72

Please sign in to comment.