MySQL issues in .NET Core/Standard Self-Servicing

Posts   
 
    
scotru
User
Posts: 104
Joined: 16-Feb-2006
# Posted on: 14-Feb-2018 20:09:00   

Greetings,

I'm experiencing a couple of problems trying to migrate to .NET Core/Standard and LLBLGen 5.3 (5.3.3 RTM currently).

1) We're getting:


System.IO.FileNotFoundException: 'Could not load file or assembly 'System.Data.SqlClient, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.'

 at SD.LLBLGen.Pro.ORMSupportClasses.PersistenceCore.CleanupDataReader(IDataReader reader, IQuery queryExecuted, Boolean disposeReader)\r\n   at SD.LLBLGen.Pro.ORMSupportClasses.EntityMaterializerBase.Materialize(Func`4 valueReadErrorHandler, String& failureErrorText)\r\n   at SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.ExecuteMultiRowRetrievalQuery(IRetrievalQuery queryToExecute, ITransaction containingTransaction, IEntityCollection collectionToFill, Boolean allowDuplicates, IEntityFields fieldsUsedForQuery, IFieldPersistenceInfo[] fieldPersistenceInfos)\r\n   at SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.PerformGetMultiAction(ITransaction containingTransaction, QueryParameters parameters)\r\n   at SD.LLBLGen.Pro.ORMSupportClasses.EntityCollectionBase`1.GetMulti(IPredicate selectFilter)\r\n   at DevArtTest.Program.PrintTermLLBL() in ....

I don't see why it's trying to call SqlClient when we are using MySQL. Here's our DQE config:


          RuntimeConfiguration.AddConnectionString("ConnectionString.MySql (MySqlDirect)", "Server=localhost;Database=XXX;Uid=YYY;Pwd=ZZZ;License Key=[redacted];");
            // Configure the DQE
            RuntimeConfiguration.ConfigureDQE<MySqlDQEConfiguration>(               
                                            c => c.AddDbProviderFactory(typeof(Devart.Data.MySql.MySqlProviderFactory)).
                                                   SetIncludeCatalogNameInObjectNamesFlag(false)
                                                   );

Is there a System.Data.SqlClient dependency even when using MySQL? It does seem to work if we add the reference to that.

2) Our 2nd issue happens both in .NET Full and in .NET Core. Even if we set: SetIncludeCatalogNameInObjectNamesFlag(false) Our generated code appears to rely on a matching catalog name.

Specifically it's included in InitXXXEntityMappings calls to AddElementMapping in the generated PersistenceInfoProvider.cs

How can we go about specifying the catalog name at runtime for MySQL?

Thanks for your help!

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 15-Feb-2018 09:10:41   

We'll look into it.

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 15-Feb-2018 10:59:17   

scotru wrote:

Greetings,

I'm experiencing a couple of problems trying to migrate to .NET Core/Standard and LLBLGen 5.3 (5.3.3 RTM currently).

1) We're getting:


System.IO.FileNotFoundException: 'Could not load file or assembly 'System.Data.SqlClient, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.'

 at SD.LLBLGen.Pro.ORMSupportClasses.PersistenceCore.CleanupDataReader(IDataReader reader, IQuery queryExecuted, Boolean disposeReader)\r\n   at SD.LLBLGen.Pro.ORMSupportClasses.EntityMaterializerBase.Materialize(Func`4 valueReadErrorHandler, String& failureErrorText)\r\n   at SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.ExecuteMultiRowRetrievalQuery(IRetrievalQuery queryToExecute, ITransaction containingTransaction, IEntityCollection collectionToFill, Boolean allowDuplicates, IEntityFields fieldsUsedForQuery, IFieldPersistenceInfo[] fieldPersistenceInfos)\r\n   at SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.PerformGetMultiAction(ITransaction containingTransaction, QueryParameters parameters)\r\n   at SD.LLBLGen.Pro.ORMSupportClasses.EntityCollectionBase`1.GetMulti(IPredicate selectFilter)\r\n   at DevArtTest.Program.PrintTermLLBL() in ....

I don't see why it's trying to call SqlClient when we are using MySQL. Here's our DQE config:


          RuntimeConfiguration.AddConnectionString("ConnectionString.MySql (MySqlDirect)", "Server=localhost;Database=XXX;Uid=YYY;Pwd=ZZZ;License Key=[redacted];");
            // Configure the DQE
            RuntimeConfiguration.ConfigureDQE<MySqlDQEConfiguration>(               
                                            c => c.AddDbProviderFactory(typeof(Devart.Data.MySql.MySqlProviderFactory)).
                                                   SetIncludeCatalogNameInObjectNamesFlag(false)
                                                   );

Is there a System.Data.SqlClient dependency even when using MySQL? It does seem to work if we add the reference to that.

This is caused by the fact the SqlAzure recovery strategy is part of the ORMSupportClasses, and that relies on SqlClient as it refers to SqlException. Before this wasn't noticed as SqlClient is part of the .NET framework and always present. However with .net core you have to install it separately. We can't do this in another way as it would require moving the SqlAzure recovery strategy to another assembly, namely the SQLServer DQE which isn't referenced by most people in the code they'll use the strategy and a breaking change for almost all code using this strategy.

We did notice that we didn't include this dependency in our nuget spec file for ORMSupportClasses for netstandard2.0. We'll correct this. For now install the sqlclient package separately using nuget or paket.

2) Our 2nd issue happens both in .NET Full and in .NET Core. Even if we set: SetIncludeCatalogNameInObjectNamesFlag(false) Our generated code appears to rely on a matching catalog name.

Specifically it's included in InitXXXEntityMappings calls to AddElementMapping in the generated PersistenceInfoProvider.cs

How can we go about specifying the catalog name at runtime for MySQL?

We'll look into this issue, it might be the setting isn't applied properly.

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 15-Feb-2018 14:02:31   

The bug is so stupid flushed


public override string CreateObjectName(string catalogName, string schemaName, string elementName)
{
    var fragments = new QueryFragments(".", 16);
    string catalogNameToUse = catalogName;
    DynamicQueryEngineBase dqe = new DynamicQueryEngine();
    if(DynamicQueryEngine.IncludeCatalogNameInObjectNames && !string.IsNullOrEmpty(catalogNameToUse))
    {
        catalogNameToUse = dqe.GetNewCatalogName(this.GetNewPerCallCatalogName(catalogNameToUse));
    }
    AppendValidIdentifier(fragments, catalogNameToUse);
    AppendValidIdentifier(fragments, elementName);
    return fragments.ToString();
}

Bonus points if you can spot it wink

Fixing now.

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 19-Feb-2018 16:26:49   

Fix is now available in v5.2.7/5.3.4 hotfix builds

Frans Bouma | Lead developer LLBLGen Pro
rlucassen
User
Posts: 22
Joined: 25-Oct-2013
# Posted on: 15-Apr-2019 12:04:51   

Hi Otis,

i know this is a old thread but i just started using llblgen 5.5 in a .net core 2 console app.

I Use MySql but llblgen wants a SqlClient

It seems like the issue is still occuring.


RuntimeConfiguration.ConfigureDQE<MySqlDQEConfiguration>(
c => c.AddDbProviderFactory(typeof(Devart.Data.MySql.MySqlProviderFactory)));


Could not load file or assembly 'System.Data.SqlClient, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.

  at SD.LLBLGen.Pro.ORMSupportClasses.PersistenceCore.CleanupDataReader(IDataReader reader, IQuery queryExecuted, Boolean disposeReader)
   at SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.ExecuteSingleRowRetrievalQuery(IRetrievalQuery queryToExecute, ITransaction containingTransaction, IEntityFields fieldsToFill, IFieldPersistenceInfo[] fieldPersistenceInfos)
   at SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.PerformFetchEntityAction(IEntity entityToFetch, ITransaction containingTransaction, IPredicateExpression selectFilter, IPrefetchPath prefetchPathToUse, Context contextToUse, ExcludeIncludeFieldsList excludedIncludedFields)
   at SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.FetchExisting(IEntity entityToFetch, ITransaction containingTransaction, IPrefetchPath prefetchPathToUse, Context contextToUse, ExcludeIncludeFieldsList excludedIncludedFields)

SupportClasses Version 5.5.1

Walaa avatar
Walaa
Support Team
Posts: 14946
Joined: 21-Aug-2005
# Posted on: 15-Apr-2019 20:15:15   

I just installed the SD.LLBLGen.Pro.ORMSupportClasses from Nuget (v.5.5.2), and it has the dependency to the SQLClient library. I also see this dependency on all previous versions.

Please use Nuget to deploy the ORMSupportClasses.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 16-Apr-2019 09:37:22   

yes the dependency on the sqlclient is in the ormsupportclasses, which is needed for the SqlAzure strategy for transient error recovery. We can't move that class as that would break all code using it, so we kept it there, with the consequence that it requires that dependency.

Frans Bouma | Lead developer LLBLGen Pro
rlucassen
User
Posts: 22
Joined: 25-Oct-2013
# Posted on: 16-Apr-2019 11:14:24   

Otis wrote:

Fix is now available in v5.2.7/5.3.4 hotfix builds

I assumed it was fixed but im guessing the was something else

Walaa avatar
Walaa
Support Team
Posts: 14946
Joined: 21-Aug-2005
# Posted on: 16-Apr-2019 16:26:34   

That was for the CatalogName overwrite, the second issue in the original message.