Bug in SqlServer migration?
See original GitHub issueIn the fold Elsa.Persistence.EntityFrameworkCore,I run the cmd:
SET EF_PROVIDER=SqlServer
SET EF_CONNECTIONSTRING=“Server=localhost; Database=elsadb; Trusted_Connection=True;”
dotnet ef database update
but I get the wrong msg:
Executing DbCommand [Parameters=[], CommandType=‘Text’, CommandTimeout=‘60’]
CREATE DATABASE [elsadb];
Executing DbCommand [Parameters=[], CommandType=‘Text’, CommandTimeout=‘60’]
IF SERVERPROPERTY(‘EngineEdition’) <> 5
BEGIN
ALTER DATABASE [elsadb] SET READ_COMMITTED_SNAPSHOT ON;
END;
Executing DbCommand [Parameters=[], CommandType=‘Text’, CommandTimeout=‘30’]
CREATE TABLE [__EFMigrationsHistory] (
[MigrationId] nvarchar(150) NOT NULL,
[ProductVersion] nvarchar(32) NOT NULL,
CONSTRAINT [PK___EFMigrationsHistory] PRIMARY KEY ([MigrationId])
);
Executing DbCommand [Parameters=[], CommandType=‘Text’, CommandTimeout=‘30’]
SELECT OBJECT_ID(N’[__EFMigrationsHistory]');
Executing DbCommand [Parameters=[], CommandType=‘Text’, CommandTimeout=‘30’]
SELECT [MigrationId], [ProductVersion]
FROM [__EFMigrationsHistory]
ORDER BY [MigrationId];
Applying migration ‘20191116105145_InitialCreate’.
Executing DbCommand [Parameters=[], CommandType=‘Text’, CommandTimeout=‘30’]
CREATE TABLE [WorkflowDefinitionVersions] (
[Id] INTEGER NOT NULL,
[VersionId] TEXT NULL,
[DefinitionId] TEXT NULL,
[Version] INTEGER NOT NULL,
[Name] TEXT NULL,
[Description] TEXT NULL,
[Variables] TEXT NULL,
[IsSingleton] INTEGER NOT NULL,
[IsDisabled] INTEGER NOT NULL,
[IsPublished] INTEGER NOT NULL,
[IsLatest] INTEGER NOT NULL,
CONSTRAINT [PK_WorkflowDefinitionVersions] PRIMARY KEY ([Id])
);
Executing DbCommand [Parameters=[], CommandType=‘Text’, CommandTimeout=‘30’]
CREATE TABLE [WorkflowInstances] (
[Id] INTEGER NOT NULL,
[InstanceId] TEXT NULL,
[DefinitionId] TEXT NULL,
[Version] INTEGER NOT NULL,
[Status] TEXT NOT NULL,
[CorrelationId] TEXT NULL,
[CreatedAt] TEXT(48) NOT NULL,
[StartedAt] TEXT(48) NULL,
[FinishedAt] TEXT(48) NULL,
[FaultedAt] TEXT(48) NULL,
[AbortedAt] TEXT(48) NULL,
[Scopes] TEXT NULL,
[Input] TEXT NULL,
[ExecutionLog] TEXT NULL,
[Fault] TEXT NULL,
CONSTRAINT [PK_WorkflowInstances] PRIMARY KEY ([Id])
);
Failed executing DbCommand (5ms) [Parameters=[], CommandType=‘Text’, CommandTimeout=‘30’]
CREATE TABLE [WorkflowInstances] (
[Id] INTEGER NOT NULL,
[InstanceId] TEXT NULL,
[DefinitionId] TEXT NULL,
[Version] INTEGER NOT NULL,
[Status] TEXT NOT NULL,
[CorrelationId] TEXT NULL,
[CreatedAt] TEXT(48) NOT NULL,
[StartedAt] TEXT(48) NULL,
[FinishedAt] TEXT(48) NULL,
[FaultedAt] TEXT(48) NULL,
[AbortedAt] TEXT(48) NULL,
[Scopes] TEXT NULL,
[Input] TEXT NULL,
[ExecutionLog] TEXT NULL,
[Fault] TEXT NULL,
CONSTRAINT [PK_WorkflowInstances] PRIMARY KEY ([Id])
);
Microsoft.Data.SqlClient.SqlException (0x80131904): 第 7 个列、参数或变量: 不能对数据类型 text 指定列宽。
at Microsoft.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction) in E:\agent1\_work\31\s\src\Microsoft.Data.SqlClient\netcore\src\Microsoft\Data\SqlClient\SqlConnection.cs:line 1591 at Microsoft.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action
1 wrapCloseInAction) in E:\agent1_work\31\s\src\Microsoft.Data.SqlClient\netcore\src\Microsoft\Data\SqlClient\SqlInternalConnection.cs:line 618
at Microsoft.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) in E:\agent1_work\31\s\src\Microsoft.Data.SqlClient\netcore\src\Microsoft\Data\SqlClient\TdsParser.cs:line 1169
at Microsoft.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) in E:\agent1_work\31\s\src\Microsoft.Data.SqlClient\netcore\src\Microsoft\Data\SqlClient\TdsParser.cs:line 1719
at Microsoft.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean isAsync, Int32 timeout, Boolean asyncWrite) in E:\agent1_work\31\s\src\Microsoft.Data.SqlClient\netcore\src\Microsoft\Data\SqlClient\SqlCommand.cs:line 2857
at Microsoft.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource1 completion, Boolean sendToPipe, Int32 timeout, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry, String methodName) in E:\agent1\_work\31\s\src\Microsoft.Data.SqlClient\netcore\src\Microsoft\Data\SqlClient\SqlCommand.cs:line 1395 at Microsoft.Data.SqlClient.SqlCommand.ExecuteNonQuery() in E:\agent1\_work\31\s\src\Microsoft.Data.SqlClient\netcore\src\Microsoft\Data\SqlClient\SqlCommand.cs:line 974 at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteNonQuery(RelationalCommandParameterObject parameterObject) at Microsoft.EntityFrameworkCore.Migrations.MigrationCommand.ExecuteNonQuery(IRelationalConnection connection, IReadOnlyDictionary
2 parameterValues)
at Microsoft.EntityFrameworkCore.Migrations.Internal.MigrationCommandExecutor.ExecuteNonQuery(IEnumerable`1 migrationCommands, IRelationalConnection connection)
at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.Migrate(String targetMigration)
at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.UpdateDatabase(String targetMigration, String contextType)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabaseImpl(String targetMigration, String contextType)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabase.<>c__DisplayClass0_0.<.ctor>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
ClientConnectionId:7051440a-ef14-4099-a858-d4910d2297db
Error Number:2716,State:1,Class:16
第 7 个列、参数或变量: 不能对数据类型 text 指定列宽。
is this a bug? thanks
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (2 by maintainers)
Top GitHub Comments
hi,maybe this can help you
open powershell, in powershell write this:
$Env:EF_CONNECTIONSTRING = "Server=(localdb)\MSSQLLocalDB;Database=OrquestadorDB;User=ELSA;Password=ELSAADMIN!;"
(this work for SqlServer Express from visual studio 2019 community)
then check if env var was ok:
$Env:EF_CONNECTIONSTRING
and run migrations in same powershell windowdotnet ef database update --context SqlServerContext
It works. thank you, sfmskywalker.Great job