EF Core migration's SQL script for computed column expression differs depending on the way the column is being handled #27323
Labels
area-migrations
customer-reported
punted-for-7.0
Originally planned for the EF Core 7.0 (EF7) release, but moved out due to resource constraints.
type-bug
Milestone
SQL expression for computed columns varies between table creation and individual column creation.
Migration code:
Generated SQL script code:
This script portion generated by EF Core CLI is invalid for the SQL Server most recent versions.
Basically, a verbatim string that could contain
\r\n
characters in its content (used to make the original code more readable by developers), is parsed into a script that is not correctly parsed by SQL Server (neither SQL Server Development edition nor Azure DevOps Release tasks).Now, on the other side, for when the table is being created from scratch, this is what is generated on both sides:
In the
CreateTable()
method from the migration, the specific field is generated this way:and the SQL script code that this generates is the following:
As you can see, the computed column expression there is not parsed as a dynamic query executed with
EXEC()
SQL function... And there's no problem with having the same verbatim string with carrier returns and new line characters in it.I would assume the mechanism for generating both code snippets is different for each case, thus the difference that I'm noticing...
Shouldn't this be unified in order to be able to generate a more consistent code?
Include provider and version information
EF Core version: 6.0.1
Database provider: Microsoft.EntityFrameworkCore.SqlServer)
Target framework: .NET 6.0
Operating system: Any
IDE: N/A
The text was updated successfully, but these errors were encountered: