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.

Unable to reverse engineer stored procedure using TVP parameter with NVARCHAR(MAX) column

See original GitHub issue

Unable to reverse engineer stored procedure using TVP as parameter because the TVP includes columns with NVARCHAR(MAX).

Error Output:

Unable to get result set shape for PROCEDURE 'dbo.MyProcedure'
System.Data.DuplicateNameException: A column named 'ColumnName' already belongs to this DataTable.
   at System.Data.DataColumnCollection.RegisterColumnName(String name, DataColumn column)
   at System.Data.DataColumnCollection.BaseAdd(DataColumn column)
   at System.Data.DataColumnCollection.AddAt(Int32 index, DataColumn column)
   at RevEng.Core.Procedures.SqlServerStoredProcedureModelFactory.GetDataTableFromSchema(ModuleParameter parameter, SqlConnection connection) in C:\Code\EFCorePowerTools\src\GUI\RevEng.Core\Procedures\SqlServerStoredProcedureModelFactory.cs:line 155
   at RevEng.Core.Procedures.SqlServerStoredProcedureModelFactory.GetAllResultSets(SqlConnection connection, Routine module, Boolean singleResult) in C:\Code\EFCorePowerTools\src\GUI\RevEng.Core\Procedures\SqlServerStoredProcedureModelFactory.cs:line 83
   at RevEng.Core.Procedures.SqlServerStoredProcedureModelFactory.GetResultElementLists(SqlConnection connection, Routine module, Boolean multipleResults, Boolean useLegacyResultSetDiscovery) in C:\Code\EFCorePowerTools\src\GUI\RevEng.Core\Procedures\SqlServerStoredProcedureModelFactory.cs:line 62
   at RevEng.Core.Procedures.SqlServerRoutineModelFactory.GetRoutines(String connectionString, ModuleModelFactoryOptions options) in C:\Code\EFCorePowerTools\src\GUI\RevEng.Core\Routines\SqlServerRoutineModelFactory.cs:line 25

I noticed that recent changes to SqlServerStoredProcedureModelFactory.GetDataTableFromSchema don’t compensate for the sysname datatypes with the same name returned alongside NVARCHAR(MAX). Maybe we filter those out?

EF Core version in use: EF Core 6

Is Handlebars used: no

EF Core Power Tools version: 2.5.963

Database engine: SQL Server, Azure SQL

Visual Studio version: Visual Studio 2022 - Preview 4

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ErikEJcommented, Apr 28, 2022

Fixed in latest daily, please let me know if it works for you

1reaction
alekoo73commented, Apr 28, 2022

@ErikEJ Thanks ,now it works

Read more comments on GitHub >

github_iconTop Results From Across the Web

Facing issue connecting stored procedure with nvarchar(max ...
As a work around i changed variable to nvarchar(255) and then cast it to int in query it worked.
Read more >
nvarchar(max) still being truncated
So I'm writing a stored procedure in MS SQL Server 2008. It's a really long query and I have to write it dynamically,...
Read more >
Release notes · ErikEJ/EFCorePowerTools Wiki
Unable to reverse engineer stored procedure using SET FMTONLY with TVP parameter with NVARCHAR(MAX) column #1361; Unable to reverse engineer ...
Read more >
Consuming JSON Strings in SQL Server - Simple Talk
The values, or name/value pairs are retrieved from the string table and stored in the hierarchy table. Gradually, the JSON document is eaten ......
Read more >
Reducing the Size of your Database in SQL Server 2005/SP2
This storage format lets you reduce the size of your table significantly if the table has one of more columns of type decimal...
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