Unhandled exception. Microsoft.Data.SqlClient.SqlException (0x80131904): Invalid collation 'ascii_general_ci'.
Is there an existing issue for this?
- [ ] I have searched the existing issues
Description
I got error while execute DbMigrator in startup template.
Reproduction Steps
No response
Expected behavior
No response
Actual behavior
No response
Regression?
No response
Known Workarounds
No response
Version
ABP Framwork V8.1.3
User Interface
MVC
Database Provider
EF Core (Default)
Tiered or separate authentication server
Separate Auth Server
Operation System
Windows (Default)
Other information
No response
detail message:
[10:31:13 INF] Started database migrations...
[10:31:13 INF] Migrating schema for host database...
[10:31:14 ERR] Failed executing DbCommand (2ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
CREATE TABLE [AbpAuditLogs] (
[Id] char(36) COLLATE ascii_general_ci NOT NULL,
[ApplicationName] varchar(96) NULL,
[UserId] char(36) COLLATE ascii_general_ci NULL,
[UserName] varchar(256) NULL,
[TenantId] char(36) COLLATE ascii_general_ci NULL,
[TenantName] varchar(64) NULL,
[ImpersonatorUserId] char(36) COLLATE ascii_general_ci NULL,
[ImpersonatorUserName] varchar(256) NULL,
[ImpersonatorTenantId] char(36) COLLATE ascii_general_ci NULL,
[ImpersonatorTenantName] varchar(64) NULL,
[ExecutionTime] datetime(6) NOT NULL,
[ExecutionDuration] int NOT NULL,
[ClientIpAddress] varchar(64) NULL,
[ClientName] varchar(128) NULL,
[ClientId] varchar(64) NULL,
[CorrelationId] varchar(64) NULL,
[BrowserInfo] varchar(512) NULL,
[HttpMethod] varchar(16) NULL,
[Url] varchar(256) NULL,
[Exceptions] longtext NULL,
[Comments] varchar(256) NULL,
[HttpStatusCode] int NULL,
[ExtraProperties] longtext NOT NULL,
[ConcurrencyStamp] varchar(40) NOT NULL,
CONSTRAINT [PK_AbpAuditLogs] PRIMARY KEY ([Id])
);
Unhandled exception. Microsoft.Data.SqlClient.SqlException (0x80131904): Invalid collation 'ascii_general_ci'.
Invalid collation 'ascii_general_ci'.
Invalid collation 'ascii_general_ci'.
Invalid collation 'ascii_general_ci'.
Invalid collation 'ascii_general_ci'.
at Microsoft.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at Microsoft.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at Microsoft.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at Microsoft.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at Microsoft.Data.SqlClient.SqlCommand.InternalEndExecuteNonQuery(IAsyncResult asyncResult, Boolean isInternal, String endMethod)
at Microsoft.Data.SqlClient.SqlCommand.EndExecuteNonQueryInternal(IAsyncResult asyncResult)
at Microsoft.Data.SqlClient.SqlCommand.EndExecuteNonQueryAsync(IAsyncResult asyncResult)
at Microsoft.Data.SqlClient.SqlCommand.<>c.<InternalExecuteNonQueryAsync>b__208_1(IAsyncResult result)
at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
--- End of stack trace from previous location ---
at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteNonQueryAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteNonQueryAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteNonQueryAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Migrations.Internal.MigrationCommandExecutor.ExecuteNonQueryAsync(IEnumerable`1 migrationCommands, IRelationalConnection connection, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Migrations.Internal.MigrationCommandExecutor.ExecuteNonQueryAsync(IEnumerable`1 migrationCommands, IRelationalConnection connection, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Migrations.Internal.MigrationCommandExecutor.ExecuteNonQueryAsync(IEnumerable`1 migrationCommands, IRelationalConnection connection, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Migrations.Internal.MigrationCommandExecutor.ExecuteNonQueryAsync(IEnumerable`1 migrationCommands, IRelationalConnection connection, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.MigrateAsync(String targetMigration, CancellationToken cancellationToken)
at Acme.BookStore.EntityFrameworkCore.EntityFrameworkCoreBookStoreDbSchemaMigrator.MigrateAsync() in C:\source-code\samples\Acme.BookStore\src\Acme.BookStore.EntityFrameworkCore\EntityFrameworkCore\EntityFrameworkCoreBookStoreDbSchemaMigrator.cs:line 29
at Acme.BookStore.Data.BookStoreDbMigrationService.MigrateDatabaseSchemaAsync(Tenant tenant) in C:\source-code\samples\Acme.BookStore\src\Acme.BookStore.Domain\Data\BookStoreDbMigrationService.cs:line 95
at Acme.BookStore.Data.BookStoreDbMigrationService.MigrateAsync() in C:\source-code\samples\Acme.BookStore\src\Acme.BookStore.Domain\Data\BookStoreDbMigrationService.cs:line 52
at Acme.BookStore.DbMigrator.DbMigratorHostedService.StartAsync(CancellationToken cancellationToken) in C:\source-code\samples\Acme.BookStore\src\Acme.BookStore.DbMigrator\DbMigratorHostedService.cs:line 36
at Microsoft.Extensions.Hosting.Internal.Host.<StartAsync>b__15_1(IHostedService service, CancellationToken token)
at Microsoft.Extensions.Hosting.Internal.Host.ForeachService[T](IEnumerable`1 services, CancellationToken token, Boolean concurrent, Boolean abortOnFirstException, List`1 exceptions, Func`3 operation)
at Microsoft.Extensions.Hosting.Internal.Host.<StartAsync>g__LogAndRethrow|15_3(<>c__DisplayClass15_0&)
at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
at Acme.BookStore.DbMigrator.Program.Main(String[] args) in C:\source-code\samples\Acme.BookStore\src\Acme.BookStore.DbMigrator\Program.cs:line 30
at Acme.BookStore.DbMigrator.Program.<Main>(String[] args)
ClientConnectionId:b11207e2-1789-4a71-8a5c-88bdcbcd6dff
Error Number:448,State:2,Class:16
Please share the steps to reproduce this? What's the DB provider are you using?
Step1. Create solution >abp new Acme.BookStore --tiered --theme basic -csf
Step2. Open solution with Visual Studio 2022 Comunity
Step3. Run project Acme.BookStore.DbMigrator
Then, error appeared.
DB provider is (localdb)\MSSQLLocalDB
Please try to run dotnet ef migrations script command in Acme.BookStore.EntityFrameworkCore project.
Acme.BookStore.EntityFrameworkCore % dotnet ef migrations script
Build started...
Build succeeded.
IF OBJECT_ID(N'[__EFMigrationsHistory]') IS NULL
BEGIN
CREATE TABLE [__EFMigrationsHistory] (
[MigrationId] nvarchar(150) NOT NULL,
[ProductVersion] nvarchar(32) NOT NULL,
CONSTRAINT [PK___EFMigrationsHistory] PRIMARY KEY ([MigrationId])
);
END;
GO
BEGIN TRANSACTION;
GO
CREATE TABLE [AbpAuditLogs] (
[Id] uniqueidentifier NOT NULL,
[ApplicationName] nvarchar(96) NULL,
[UserId] uniqueidentifier NULL,
[UserName] nvarchar(256) NULL,
[TenantId] uniqueidentifier NULL,
[TenantName] nvarchar(64) NULL,
[ImpersonatorUserId] uniqueidentifier NULL,
[ImpersonatorUserName] nvarchar(256) NULL,
[ImpersonatorTenantId] uniqueidentifier NULL,
[ImpersonatorTenantName] nvarchar(64) NULL,
[ExecutionTime] datetime2 NOT NULL,
[ExecutionDuration] int NOT NULL,
[ClientIpAddress] nvarchar(64) NULL,
[ClientName] nvarchar(128) NULL,
[ClientId] nvarchar(64) NULL,
[CorrelationId] nvarchar(64) NULL,
[BrowserInfo] nvarchar(512) NULL,
[HttpMethod] nvarchar(16) NULL,
[Url] nvarchar(256) NULL,
[Exceptions] nvarchar(max) NULL,
[Comments] nvarchar(256) NULL,
[HttpStatusCode] int NULL,
[ExtraProperties] nvarchar(max) NOT NULL,
[ConcurrencyStamp] nvarchar(40) NOT NULL,
CONSTRAINT [PK_AbpAuditLogs] PRIMARY KEY ([Id])
);
GO
And then execute SQL script manual?
Please share the script of CREATE TABLE [AbpAuditLogs]
CREATE TABLE [AbpAuditLogs] (
[Id] char(36) COLLATE ascii_general_ci NOT NULL,
[ApplicationName] varchar(96) NULL,
[UserId] char(36) COLLATE ascii_general_ci NULL,
[UserName] varchar(256) NULL,
[TenantId] char(36) COLLATE ascii_general_ci NULL,
[TenantName] varchar(64) NULL,
[ImpersonatorUserId] char(36) COLLATE ascii_general_ci NULL,
[ImpersonatorUserName] varchar(256) NULL,
[ImpersonatorTenantId] char(36) COLLATE ascii_general_ci NULL,
[ImpersonatorTenantName] varchar(64) NULL,
[ExecutionTime] datetime(6) NOT NULL,
[ExecutionDuration] int NOT NULL,
[ClientIpAddress] varchar(64) NULL,
[ClientName] varchar(128) NULL,
[ClientId] varchar(64) NULL,
[CorrelationId] varchar(64) NULL,
[BrowserInfo] varchar(512) NULL,
[HttpMethod] varchar(16) NULL,
[Url] varchar(256) NULL,
[Exceptions] longtext NULL,
[Comments] varchar(256) NULL,
[HttpStatusCode] int NULL,
[ExtraProperties] longtext NOT NULL,
[ConcurrencyStamp] varchar(40) NOT NULL,
CONSTRAINT [PK_AbpAuditLogs] PRIMARY KEY ([Id])
);
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.