question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Column, parameter, or variable #1: Cannot specify a column width on data type text.

See original GitHub issue

I get this error when running Update-Migration.

///Error message Start

Applying migration ‘20200906170827_V1.0.0.1’. Failed executing DbCommand (8ms) [Parameters=[], CommandType=‘Text’, CommandTimeout=‘30’] CREATE TABLE [AccountGroups_DBSet] ( [GroupName] TEXT(50) NOT NULL, [GroupParent] TEXT(50) NULL, [BalanceSheetSide] TEXT(255) NULL, [Description] TEXT(255) NULL, [IsHidden] INTEGER NOT NULL, [GroupEnd] TEXT(50) NULL, [IsUnderBudgetControl] INTEGER NOT NULL, [BudgetAmount] TEXT(64) NULL, [IsUnderLocationControl] INTEGER NOT NULL, [Location] TEXT(50) NULL, [TxnID] TEXT(36) NOT NULL, [SearchKey] TEXT(150) NULL, [RecordVersion] INTEGER NOT NULL, [CreatedBy] TEXT(50) NOT NULL, [LastUpdatedBy] TEXT(50) NULL, [CreatedOn] TEXT(48) NOT NULL, [LastUpdatedOn] TEXT(48) NULL, [Company] TEXT(100) NULL, CONSTRAINT [PK_AccountGroups_DBSet] PRIMARY KEY ([GroupName]) ); Microsoft.Data.SqlClient.SqlException (0x80131904): Column, parameter, or variable #1: Cannot specify a column width on data type text. at Microsoft.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) in …More stack trace omitted

Error Number:2716,State:1,Class:16 Column, parameter, or variable #1: Cannot specify a column width on data type text.

///Error message End

But when I generate SQL Script using dbContext.Database.GenerateCreateScript(), the generated script is different and also works when creating database schema manually. Look at what SQL script saved in a file from the same migration looks like :

CREATE TABLE [AccountGroups_DBSet] ( [GroupName] nvarchar(50) NOT NULL, [GroupParent] nvarchar(50) NULL, [BalanceSheetSide] nvarchar(255) NULL, [Description] nvarchar(255) NULL, [IsHidden] bit NOT NULL, [GroupEnd] nvarchar(50) NULL, [IsUnderBudgetControl] bit NOT NULL, [BudgetAmount] decimal(18,2) NULL, [IsUnderLocationControl] bit NOT NULL, [Location] nvarchar(50) NULL, [TxnID] nvarchar(36) NOT NULL, [SearchKey] nvarchar(150) NULL, [RecordVersion] bigint NOT NULL, [CreatedBy] nvarchar(50) NOT NULL, [LastUpdatedBy] nvarchar(50) NULL, [CreatedOn] datetime2 NOT NULL, [LastUpdatedOn] datetime2 NULL, [Company] nvarchar(100) NULL, CONSTRAINT [PK_AccountGroups_DBSet] PRIMARY KEY ([GroupName]) ); GO

EF Core version: Database provider: (e.g. Microsoft.EntityFrameworkCore.SqlServer) Target framework: (e.g. .NET Core 3.0) Operating system: IDE: (e.g. Visual Studio 2019 16.3)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

8reactions
ErikEJcommented, Sep 8, 2020

Looks like you are mixing SQLite and SQL Server migrations ??

0reactions
himanshukodwanicommented, Sep 8, 2020

Thanks a lot

Get Outlook for Androidhttps://aka.ms/ghei36


From: Shay Rojansky notifications@github.com Sent: Tuesday, September 8, 2020 8:37:22 PM To: dotnet/efcore efcore@noreply.github.com Cc: himanshukodwani himanshukodwani@hotmail.com; Author author@noreply.github.com Subject: Re: [dotnet/efcore] Column, parameter, or variable #1: Cannot specify a column width on data type text. (#22424)

You probably want to take a look at this doc pagehttps://docs.microsoft.com/en-us/ef/core/managing-schemas/migrations/providers?tabs=dotnet-core-cli, about managing migrations in a multi-database scenario.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/dotnet/efcore/issues/22424#issuecomment-688941191, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AJ7O4IUB427LSDURZBYKFI3SEZCCVANCNFSM4Q4X2S7A.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot specify a column width on data type int - sql
I've read and reread the code and can't seem to figure out why I am getting the following error: "Msg 2716, Level 16,...
Read more >
Why I get this sql error when creating a table?
Column, parameter, or variable #3: Cannot specify a column width on data type int. Something is wrong with the line: OrderPrice Integer(10) NULL ......
Read more >
Getting an error message "Cannot specify a column width ...
Text data type or nText data type does not support a "width" property, you can't specify column length. If you're creating the table...
Read more >
Cannot specify a column width on data type ntext
Looks like there is a bug in the table creation code where it attempts to specify the width of the ntext column which...
Read more >
Error "Cannot specify a column width on data type sysname ...
Error "Cannot specify a column width on data type sysname" occurs when creating a table with a SYSNAME datatype using the JDBC 5.1...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found