jonwagner / Insight.Database

Fast, lightweight .NET micro-ORM
Other
861 stars 145 forks source link

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

Closed madrianr closed 6 months ago

madrianr commented 6 months ago

Describe the bug

After Upgrading to Version 8.0 I get the follwing error: _NotImplementedException: Cannot derive parameters for the stored procedure SELECTFachgruppenuser. 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();

jonwagner commented 6 months ago

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:

madrianr commented 6 months ago

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