ExecutesSqlRaw throwing weird error about "SqlParameterCollection only accepts non-null SqlParameter type objects"
See original GitHub issueI’m trying to execute a raw sql statement with a sql parameter that is not null but I’m getting an odd error.
“UPDATE [a] SET [a].[IsDeleted] = @param_0 FROM [dbo].[Addresses] AS [a] WHERE [a].[IsDeleted] = 0”
“SqlParameterCollection only accepts non-null SqlParameter type objects”
Steps to reproduce
Further technical details
EF Core version: 3 Database provider: Microsoft.EntityFrameworkCore.SqlServer Target framework: .NET Core 3.0 Operating system: Windows 10 1903 - 18362.356 IDE: Visual Studio 2019 16.3.2
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
only accepts non-null SqlParameter type objects - ...
Database.ExecuteSqlRaw - only accepts non-null SqlParameter type objects · The exception clearly states the issue. · I think I removed the null ......
Read more >The SqlParameterCollection only accepts non-null ...
ExecutesSqlRaw throwing weird error about "SqlParameterCollection only accepts non-null SqlParameter type objects" #18218.
Read more >[Solved] The SqlParameterCollection only accepts non-null ...
The SqlParameterCollection only accepts non-null SqlParameter type objects. Parameter name: value.
Read more >The SqlParameterCollection only accepts non-null ...
Hi after successfully version migration i am trying to call some apis to fetch records for the components. But i am getting this...
Read more >EF Core 3 Stored Procedure Example - C# Tips - C# Tip Article
SqlParameter(...)" statement in the example above. "The SqlParameterCollection only accepts non-null SqlParameter type objects, not SqlParameter objects.".
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Have you tried:
Replace:
using System.Data.SqlClient;
withusing Microsoft.Data.SqlClient;
EF Core 3.0 changed its dependency from System.Data.SqlClient to the newly-released Microsoft.Data.SqlClient. This doesn’t affect most scenarios, but if you’re passing SqlParameter instances to raw SQL methods, you indeed need to make sure you’re passing the right type.
Opened https://github.com/aspnet/EntityFramework.Docs/issues/1815 to document.