Community,

I'm setting up the dotConnect for MySql Provider from Devart in combination with Entity Framework Extensions from zzzprojects.

Unfortunately the connection is not stable, by using AddDbContextPool. The connection is stable by using AddDbContext.

I have tried to register the Provider over options.ReplaceService but don't know which type i have to use.

The reason i have tried to Register the Service explicit is by using 'BulkSaveChangesAsync'. I get the error 'The Provider could not be resolved. You must explicitly set the Provider.'

It would be great if someone has advice for me ?

services.AddDbContextPool<DbContext>(options =>
  {   options.UseMySql(Configuration.GetConnectionString("Default"));
      options.UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking);
  });

Dependencies:

<ItemGroup>
    <PackageReference Include="AutoMapper" Version="8.0.0" />
    <PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="6.0.0" />
    <PackageReference Include="AWSSDK.Extensions.NETCore.Setup" Version="3.3.6" />
    <PackageReference Include="AWSSDK.S3" Version="3.3.31.10" />
    <PackageReference Include="CsvHelper" Version="12.1.2" />
    <PackageReference Include="Devart.Data.MySql.EFCore" Version="8.13.1402" />
    <PackageReference Include="Devart.Data.MySql.EFCore.Design" Version="8.13.1402" />
    <PackageReference Include="Microsoft.AspNetCore.All" />
    <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="2.2.0" />
    <PackageReference Include="Microsoft.AspNetCore.Cors" Version="2.2.0" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="2.2.4" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.2.4" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.2.4" />
    <PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
    <PackageReference Include="Swashbuckle.AspNetCore" Version="4.0.1" />
    <PackageReference Include="Z.EntityFramework.Extensions.EFCore" Version="2.5.1" />
  </ItemGroup>

Errors:

1.Unstable Connection:

System.NullReferenceException: Object reference not set to an instance of an object.
   at Devart.Data.MySql.MySqlConnection()
   at Devart.Data.MySql.MySqlConnection.Open()
  1. Use Entity Framework Extensions

    The Provider could not be resolved. You must explicitly set the Provider. at at Z.BulkOperations.BulkOperation.() at at Z.BulkOperations.BulkOperation.Execute() at at Z.BulkOperations.BulkOperation

2

There are 2 best solutions below

0
Jonathan Magnan On

Disclaimer: I'm the owner of the project Entity Framework Extensions

Devart for MySQL is not yet supported in EF Extensions

That's why you currently get that error. We will look at it on our side to try to support it.

0
Devart On

System.NullReferenceException: Object reference not set to an instance of an object. at Devart.Data.MySql.MySqlConnection()

dotConnect for MySQL v8.13.1422 includes the following fixes:

  • The bug with incorrect exception message on opening connection, when ConnectionString is not set, by .NET Standard compliant assemblies is fixed
  • The bug with reopening connections in EF Core 2 is fixed