DbProviderFactory information for compatibilitylevel wasn't properly initialized

Posts   
 
    
hotmail
User
Posts: 47
Joined: 06-Feb-2013
# Posted on: 17-Oct-2017 17:18:29   

Hello, Using LLBL v5.3(13-Oct-2017) Targeting .Net Standard 2.0, SQL Server 2016

I have the following code in my Startup class of an Asp.Net Core Web Api project (netcoreapp2.0).


        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseMvc();
            RuntimeConfiguration.AddConnectionString("ConnectionString.SQL Server (SqlClient)","data source=Dbsrv1;initial catalog=zzTest;integrated security=SSPI;persist security info=False;packet size=4096");

            RuntimeConfiguration.ConfigureDQE<SQLServerDQEConfiguration>(
                                c => c.SetDefaultCompatibilityLevel(SqlServerCompatibilityLevel.SqlServer2012));
        }

when i run the application i get following exception


DbProviderFactory information for compatibilitylevel SqlServer2012 wasn't properly initialized.
Source: SD.LLBLGen.Pro.DQE.SqlServer
Runtime Build: 5.3.0_Netstandard2x


StackTrace: at SD.LLBLGen.Pro.DQE.SqlServer.SqlServerSpecificCreator.ObtainDbProviderFactoryInfo(SqlServerCompatibilityLevel compatibilityLevel)
   at SD.LLBLGen.Pro.DQE.SqlServer.DynamicQueryEngine.Configure(SQLServerDQEConfiguration configuration)
   at zzTest.Application.Web.Startup.Configure(IApplicationBuilder app, IHostingEnvironment env) in C:\Users\zzTester\Desktop\z\Zenople.Application.Web\Startup.cs:line 37

Any help? Thanks

Walaa avatar
Walaa
Support Team
Posts: 14946
Joined: 21-Aug-2005
# Posted on: 17-Oct-2017 22:45:10   

You need to add the ProviderFactory explicitly


RuntimeConfiguration.ConfigureDQE<SQLServerDQEConfiguration>(
                c=>c.AddDbProviderFactory(typeof(System.Data.SqlClient.SqlClientFactory)));

ref: http://www.llblgen.com/Documentation/5.3/LLBLGen%20Pro%20RTF/Using%20the%20generated%20code/gencode_runtimeconfiguration.htm#dbproviderfactory

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39589
Joined: 17-Aug-2003
# Posted on: 18-Oct-2017 09:46:19   

I think we need to adjust the error information as well, e.g. by notifying they have to register a DbProviderFactory on .NET standard, even sqlclient.

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39589
Joined: 17-Aug-2003
# Posted on: 18-Oct-2017 11:43:25   

Added a more clear error message for this error on netstandard. Available in v5.3.1 hotfix (uploaded in an hour)

Frans Bouma | Lead developer LLBLGen Pro