jonwagner / Insight.Database

Fast, lightweight .NET micro-ORM

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot derive parameters for the stored procedure... Have you loaded the provider that supports SqlCommand?

madrianr opened this issue · comments

Describe the bug

After Upgrading to Version 8.0 I get the follwing error:
NotImplementedException: Cannot derive parameters for the stored procedure SELECT_Fachgruppenuser. Have you loaded the provider that supports SqlCommand?

public static IList SPSelect(HttpContext context, IDbConnection db, string sql, object parameters = null)
{
IList result = null;
IWebHostEnvironment env = (IWebHostEnvironment)context.RequestServices.GetService(typeof(IWebHostEnvironment));
result = db.Query(sql, parameters, commandType: System.Data.CommandType.StoredProcedure);
return result;
}

I have registered
using Insight.Database.Providers.MsSqlClient;
...
SqlInsightDbProvider.RegisterProvider();

  • Dotnet version: NET 8
  • Database: SQL Server
  • Library version: 8.0

v8 changes the default sql provider from System.Data.SqlClient to Microsoft.Data.SqlClient and no longer automatically packages the System.Data version by default. If you were on a previous version of Insight, you're likely using the System.Data version.

So, double check which SqlClient your code is using. If you're using System.Data.SqlClient, you should just need to:

  • Install Insight.Database.Providers.Default from NuGet. This should then automatically register the old provider.
  • In rare cases you may need to do Insight.Database.Providers.Default.SqlInsightDbProvider.RegisterProvider();

Thanks - adding Insight.Database.Providers.Default solved the problem
robert