From 310d72109c93fb28730d502ee7ba13f8852d32c0 Mon Sep 17 00:00:00 2001 From: AndriySvyryd Date: Thu, 24 Oct 2019 13:59:22 -0700 Subject: [PATCH] A test for non-default collations #7172 --- .../BatchingTest.cs | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/test/EFCore.SqlServer.FunctionalTests/BatchingTest.cs b/test/EFCore.SqlServer.FunctionalTests/BatchingTest.cs index d2d1d63d37f..a19900ead38 100644 --- a/test/EFCore.SqlServer.FunctionalTests/BatchingTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/BatchingTest.cs @@ -140,6 +140,34 @@ public void Inserts_when_database_type_is_different() context => Assert.Equal(2, context.Owners.Count())); } + [ConditionalFact] + public void Inserts_when_database_collation_is_different() + { + ExecuteWithStrategyInTransaction( + context => + { + context.Database.ExecuteSqlRaw(@" +DROP TABLE dbo.Blogs; + +ALTER TABLE dbo.Owners + DROP CONSTRAINT PK_Owners; +ALTER TABLE dbo.Owners + ALTER COLUMN Id nvarchar(450) COLLATE SQL_Latin1_General_CP1_CS_AS NOT NULL; +ALTER TABLE dbo.Owners + ALTER COLUMN Name nvarchar(MAX) COLLATE SQL_Latin1_General_CP1_CS_AS NOT NULL; +ALTER TABLE dbo.Owners ADD CONSTRAINT + PK_Owners PRIMARY KEY CLUSTERED (Id);"); + + var owner1 = new Owner { Id = "0", Name = "Zero" }; + var owner2 = new Owner { Id = "A", Name = string.Join("", Enumerable.Repeat('A', 900)) }; + context.Owners.Add(owner1); + context.Owners.Add(owner2); + + context.SaveChanges(); + }, + context => Assert.Equal(2, context.Owners.Count())); + } + [ConditionalTheory] [InlineData(3)] [InlineData(4)]