Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop scaffolding IsTableExcludedFromMigrations #21719

Merged
merged 1 commit into from
Jul 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>())));
}
}