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

Fix for issue #25116 - Microsoft.EntityFrameworkCore.Sqlite.NetTopologySuite error during migration #28476

Merged
merged 3 commits into from
Jul 20, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,8 @@ private IReadOnlyList<MigrationOperation> RewriteOperations(
ComputedColumnSql = column.ComputedColumnSql,
IsStored = column.IsStored,
Comment = column.Comment,
Collation = column.Collation
Collation = column.Collation,
Table = createTableOperation.Name
};
addColumnOperation.AddAnnotations(column.GetAnnotations());
createTableOperation.Columns.Add(addColumnOperation);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Microsoft.EntityFrameworkCore.Sqlite.Metadata.Internal;

namespace Microsoft.EntityFrameworkCore.Migrations;
using NetTopologySuite.Geometries;

public class SqliteMigrationsSqlGeneratorTest : MigrationsSqlGeneratorTestBase
{
Expand Down Expand Up @@ -968,6 +969,51 @@ public virtual void Deferred_AddColumn_defers_subsequent_CreateIndex()
");
}

[ConditionalFact]
public virtual void DropColumn_in_table_which_has_another_spatial_column()
{
Generate(
modelBuilder => modelBuilder.Entity(
"Blog",
x =>
{
x.Property<int>("Id");
x.Property<string>("Name");
x.Property<Geometry>("Position").HasColumnType("GEOMETRY").HasSrid(4326);
}),
migrationBuilder =>
{
migrationBuilder.DropColumn(
name: "Name",
table: "Blog");
});

AssertSql(
@"CREATE TABLE ""ef_temp_Blog"" (
""Id"" INTEGER NOT NULL CONSTRAINT ""PK_Blog"" PRIMARY KEY AUTOINCREMENT,
""Name"" TEXT NULL
);
SELECT AddGeometryColumn('ef_temp_Blog', 'Position', 4326, 'GEOMETRY', -1, 0);
GO

INSERT INTO ""ef_temp_Blog"" (""Id"", ""Name"", ""Position"")
SELECT ""Id"", ""Name"", ""Position""
FROM ""Blog"";
GO

PRAGMA foreign_keys = 0;
GO

DROP TABLE ""Blog"";
GO

ALTER TABLE ""ef_temp_Blog"" RENAME TO ""Blog"";
GO

PRAGMA foreign_keys = 1;
");
}

[ConditionalFact]
public virtual void RenameTable_preserves_pending_rebuilds()
{
Expand Down