Closed DimitriiBielousov closed 7 months ago
Hello @DimitriiBielousov, I've tried to reproduce this issue but it works for me. Could you run update with verbose level logging and provide the output?
Following command runs the update using dotnet ef tools: dotnet ef database update --verbose
If you don't have ef tools installed you can install it using dotnet tool install --global dotnet-ef
Hello, @Sielnix, Just FYI I'm using:
dotnet ef database update --verbose The last part of output below:
Finding DbContext classes in the project... Using context 'SnowflakeDbContext'. Finding design-time services referenced by assembly 'ProjectName'... Finding design-time services referenced by assembly 'ProjectName'... No referenced design-time services were found. Finding design-time services for provider 'EFCore.Snowflake'... Using design-time services from provider 'EFCore.Snowflake'. Finding IDesignTimeServices implementations in assembly 'ProjectName'... No design-time services were found. [01:04:54 ERR] Failed executing DbCommand (243ms) [Parameters=[], CommandType='Text', CommandTimeout='0'] EXECUTE IMMEDIATE $$ BEGIN
CREATE TABLE "__EFMigrationsHistory" (
"MigrationId" VARCHAR(150) NOT NULL,
"ProductVersion" VARCHAR(32) NOT NULL,
CONSTRAINT "PK___EFMigrationsHistory" PRIMARY KEY ("MigrationId")
);
END;
$$
Snowflake.Data.Client.SnowflakeDbException (0x80004005): Error: Uncaught exception of type 'STATEMENT_ERROR' on line 4 at position 4 : SQL compilation error:
Object '"EFMigrationsHistory"' already exists. SqlState: 42710, VendorCode: 2002, QueryId: 01b3796c-0103-9a94-0006-d901263afbd3
at Snowflake.Data.Core.SFStatement.ExecuteHelper[T,U](Int32 timeout, String sql, Dictionary2 bindings, Boolean describeOnly) at Snowflake.Data.Core.SFStatement.ExecuteSqlOtherThanPutGet(Int32 timeout, String sql, Dictionary
2 bindings, Boolean describeOnly)
at Snowflake.Data.Core.SFStatement.Execute(Int32 timeout, String sql, Dictionary`2 bindings, Boolean describeOnly)
at Snowflake.Data.Client.SnowflakeDbCommand.ExecuteInternal(Boolean describeOnly)
at Snowflake.Data.Client.SnowflakeDbCommand.ExecuteNonQuery()
at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteNonQuery(RelationalCommandParameterObject parameterObject)
at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.Migrate(String targetMigration)
at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.UpdateDatabase(String targetMigration, String connectionString, String contextType)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabaseImpl(String targetMigration, String connectionString, String contextType)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabase.<>cDisplayClass0_0.<.ctor>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
Error: Uncaught exception of type 'STATEMENT_ERROR' on line 4 at position 4 : SQL compilation error:
Object '"__EFMigrationsHistory"' already exists. SqlState: 42710, VendorCode: 2002, QueryId: 01b3796c-0103-9a94-0006-d901263afbd3
Hey @DimitriiBielousov,
Thank you for your contribution. After deeper investigation i've managed to reproduce this error. It happens, when you have non PUBLIC
schema set in connection string. This bug has been addressed and fixed in newest 8.0.3.1 release of EFCore.Snowflake. Please update the package and verify if it fixes your issue.
Hi, @Sielnix
I confirm that issue is solved in EFCore.Snowflake version 8.0.3.1. Thank you for quick fix and working on this project! All the best!
Only Initial Migration works successfully and all next are failed with errors like: "SQL compilation error: Object '"__EFMigrationsHistory"' already exists." and the same for other tables (Entities).
Every time when I do "Update-Database" next code is executed without "IF NOT EXISTS": EXECUTE IMMEDIATE $$ BEGIN
);
END; $$