From 9b52977064b1a9b7c0d3732a94b956f3b53d3be1 Mon Sep 17 00:00:00 2001 From: Andriy Svyryd Date: Mon, 17 Aug 2020 23:00:39 -0700 Subject: [PATCH] Test for issue #22092 --- .../DataAnnotationTestBase.cs | 25 ++++++++++++++----- .../DataAnnotationSqlServerTest.cs | 10 ++++++++ 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/test/EFCore.Specification.Tests/DataAnnotationTestBase.cs b/test/EFCore.Specification.Tests/DataAnnotationTestBase.cs index e303038bf7b..3c3c1608671 100644 --- a/test/EFCore.Specification.Tests/DataAnnotationTestBase.cs +++ b/test/EFCore.Specification.Tests/DataAnnotationTestBase.cs @@ -2439,25 +2439,38 @@ protected override void Seed(PoolableDbContext context) } } + protected abstract class OneBase + { + public virtual int UniqueNo { get; set; } + + public virtual Guid RowVersion { get; set; } + + public virtual string IgnoredProperty { get; set; } + + public virtual string RequiredColumn { get; set; } + + public virtual string MaxLengthProperty { get; set; } + } + [Table("Sample")] - protected class One + protected class One : OneBase { [Key] [DatabaseGenerated(DatabaseGeneratedOption.Identity)] - public int UniqueNo { get; set; } + public override int UniqueNo { get; set; } [ConcurrencyCheck] - public Guid RowVersion { get; set; } + public override Guid RowVersion { get; set; } [NotMapped] - public string IgnoredProperty { get; set; } + public override string IgnoredProperty { get; set; } [Required] [Column("Name")] - public string RequiredColumn { get; set; } + public override string RequiredColumn { get; set; } [MaxLength(10)] - public string MaxLengthProperty { get; set; } + public override string MaxLengthProperty { get; set; } public Details Details { get; set; } diff --git a/test/EFCore.SqlServer.FunctionalTests/DataAnnotationSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/DataAnnotationSqlServerTest.cs index 7cada246f41..329e3d6b603 100644 --- a/test/EFCore.SqlServer.FunctionalTests/DataAnnotationSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/DataAnnotationSqlServerTest.cs @@ -125,6 +125,16 @@ public override ModelBuilder DatabaseGeneratedOption_configures_the_property_cor return modelBuilder; } + [ConditionalFact] + public virtual void ColumnAttribute_configures_the_property_correctly() + { + var modelBuilder = CreateModelBuilder(); + modelBuilder.Entity(); + + Assert.Equal("Name", + modelBuilder.Model.FindEntityType(typeof(One)).FindProperty(nameof(One.RequiredColumn)).GetColumnName()); + } + public override ModelBuilder DatabaseGeneratedOption_Identity_does_not_throw_on_noninteger_properties() { var modelBuilder = base.DatabaseGeneratedOption_Identity_does_not_throw_on_noninteger_properties();