Skip to content

Commit

Permalink
Stop scaffolding IsTableExcludedFromMigrations (#21719)
Browse files Browse the repository at this point in the history
Fixes #21470
  • Loading branch information
roji committed Jul 22, 2020
1 parent 31c3a39 commit 840e3dc
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/EFCore.Relational/Design/AnnotationCodeGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ public virtual void RemoveAnnotationsHandledByConventions(IModel model, IDiction
/// <inheritdoc />
public virtual void RemoveAnnotationsHandledByConventions(
IEntityType entityType, IDictionary<string, IAnnotation> annotations)
=> RemoveConventionalAnnotationsHelper(entityType, annotations, IsHandledByConvention);
{
annotations.Remove(RelationalAnnotationNames.IsTableExcludedFromMigrations);

RemoveConventionalAnnotationsHelper(entityType, annotations, IsHandledByConvention);
}

/// <inheritdoc />
public virtual void RemoveAnnotationsHandledByConventions(
Expand Down
35 changes: 35 additions & 0 deletions test/EFCore.Relational.Tests/Design/AnnotationCodeGeneratorTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// 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.Linq;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.EntityFrameworkCore.TestUtilities;
using Xunit;

namespace Microsoft.EntityFrameworkCore.Design
{
public class AnnotationCodeGeneratorTest
{
[ConditionalFact]
public void IsTableExcludedFromMigrations_false_is_handled_by_convention()
{
var modelBuilder = CreateModelBuilder();
modelBuilder.Entity("foo").ToTable("foo");
var entityType = modelBuilder.Model.GetEntityTypes().Single();

var annotations = entityType.GetAnnotations().ToDictionary(a => a.Name, a => a);
CreateGenerator().RemoveAnnotationsHandledByConventions(entityType, annotations);

Assert.DoesNotContain(RelationalAnnotationNames.IsTableExcludedFromMigrations, annotations.Keys);
}

private ModelBuilder CreateModelBuilder() => RelationalTestHelpers.Instance.CreateConventionBuilder();

private AnnotationCodeGenerator CreateGenerator() => new AnnotationCodeGenerator(
new AnnotationCodeGeneratorDependencies(
new TestRelationalTypeMappingSource(
TestServiceFactory.Instance.Create<TypeMappingSourceDependencies>(),
TestServiceFactory.Instance.Create<RelationalTypeMappingSourceDependencies>())));
}
}

0 comments on commit 840e3dc

Please sign in to comment.