sqlServerCatalogNameOverwrites in dotnet core 8 where in config file?

Posts   
 
    
kakaiya
User
Posts: 171
Joined: 20-Mar-2004
# Posted on: 09-Apr-2024 17:31:18   

LLBLGen Pro version build 5.10.2.0

Problem occuring at runtime - below in exception

template group - adapter

Using IIS server ONLY (NO Kestrel server) and on Windows 2022 ONLY

.NET version - core v8

database type and version - SQL Server 2022

    <sqlServerCatalogNameOverwrites>
        <add key="INKDEV" value="???INKPROD???" />
    </sqlServerCatalogNameOverwrites>

Exception:

An unhandled exception occurred while processing the request.
SqlException: Invalid object name 'INKDEV.dbo.inkEODSiteStaffName'.
Microsoft.Data.SqlClient.SqlConnection.OnError(SqlException exception, bool breakConnection, Action<Action> wrapCloseInAction)

ORMQueryExecutionException: An exception was caught during the execution of a retrieval query: Invalid object name 'INKDEV.dbo.inkEODSiteStaffName'.. Check InnerException, QueryExecuted and Parameters of this exception to examine the cause of this exception.
SD.LLBLGen.Pro.ORMSupportClasses.RetrievalQuery.Execute(CommandBehavior behavior)

Stack Query Cookies Headers Routing
SqlException: Invalid object name 'INKDEV.dbo.inkEODSiteStaffName'.
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39730
Joined: 17-Aug-2003
# Posted on: 10-Apr-2024 09:29:11   

If you're using .NET 6+ or .net core 3.x, you have to use the runtime configuration to specify catalog name overwriting, see: https://www.llblgen.com/Documentation/5.11/LLBLGen%20Pro%20RTF/Using%20the%20generated%20code/gencode_runtimeconfiguration.htm#multi-tenancy-support-catalog-name-overwriting-sql-server-mysql as the .netstandard build of the runtime doesn't use the config file based configuration settings.

Frans Bouma | Lead developer LLBLGen Pro
kakaiya
User
Posts: 171
Joined: 20-Mar-2004
# Posted on: 10-Apr-2024 11:44:00   

Otis,

Thank you.

How to use below in dotnet core to see SQL?

..... .....

           <add key="ORMProfilerEnabled" value="false" />
</appSettings>
Walaa avatar
Walaa
Support Team
Posts: 14981
Joined: 21-Aug-2005
# Posted on: 10-Apr-2024 15:18:26   

Please follow the docs

kakaiya
User
Posts: 171
Joined: 20-Mar-2004
# Posted on: 14-Oct-2024 11:50:05   

Followed link but still do not understand about how to see simple SQL in profiler - NOT using Entity Framework and using asp.net core 8 with SQL Server 2022.

Walaa avatar
Walaa
Support Team
Posts: 14981
Joined: 21-Aug-2005
# Posted on: 14-Oct-2024 18:13:01   

Do you have the ORM Profiler tool running?

kakaiya
User
Posts: 171
Joined: 20-Mar-2004
# Posted on: 15-Oct-2024 06:27:33   

It is running and is there a link/blog I can refer to set it up. I want do it myself first.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39730
Joined: 17-Aug-2003
# Posted on: 15-Oct-2024 08:23:31   

You have to wrap the providerfactory you pass to the LLBLGen Pro's RuntimeConfiguration class at startup of your application, see: https://llblgen.com/Documentation/ORMProfiler/2.0/Getting%20Started/EnablingForProfiling.htm#net-core-2.0

Frans Bouma | Lead developer LLBLGen Pro
kakaiya
User
Posts: 171
Joined: 20-Mar-2004
# Posted on: 15-Oct-2024 10:37:32   

Hi Otis,

Thank you.

Also for providerfactory how to know whch one I am using for SQL Server 2022?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39730
Joined: 17-Aug-2003
# Posted on: 16-Oct-2024 08:34:24   

kakaiya wrote:

Hi Otis,

Thank you.

Also for providerfactory how to know whch one I am using for SQL Server 2022?

You have to specify the factory to RuntimeConfiguration, like in e.g.:

RuntimeConfiguration.ConfigureDQE<SQLServerDQEConfiguration>(
                                c => c.SetTraceLevel(TraceLevel.Verbose)
                                        .AddDbProviderFactory(typeof(System.Data.SqlClient.SqlClientFactory))
                                        .SetDefaultCompatibilityLevel(SqlServerCompatibilityLevel.SqlServer2012));

(ref )

So could you show us how you use RuntimeConfiguration in your application?

Frans Bouma | Lead developer LLBLGen Pro
kakaiya
User
Posts: 171
Joined: 20-Mar-2004
# Posted on: 16-Oct-2024 10:01:51   
                    var factoryTypeToWrap = SD.Tools.OrmProfiler.Interceptor.InterceptorCore.Initialize(Common.Constants.ApplicationName, typeof(Microsoft.Data.SqlClient.SqlClientFactory));**//not sure about System.Data.SqlClient.SqlClientFactory**

                    config.AddDbProviderFactory(factoryTypeToWrap);

also

using SQL2022 Should be using Microsoft.Data.SqlClient.SqlClientFactory vs System.Data.SqlClient.SqlClientFactory? What need to use?

Walaa avatar
Walaa
Support Team
Posts: 14981
Joined: 21-Aug-2005
# Posted on: 16-Oct-2024 10:24:08   

Correct, Microsoft.Data is the recommended provider.

kakaiya
User
Posts: 171
Joined: 20-Mar-2004
# Posted on: 16-Oct-2024 10:31:13   

Walaa wrote:

Correct, Microsoft.Data is the recommended provider.

Thank you, no worries.