We have now changed to use the code like in your post but still not fetching from the right database. (which in this case is ODInfoCenter_Dev2)
Public Function FindByEmail(email As String) As UserEntity
ErrorManager.Info("FindByEmailAsync - email:" & email)
If String.IsNullOrEmpty(email) Then
Throw New ArgumentException("Null or empty argument: email")
End If
Dim entCol As New EntityCollection(New UserEntityFactory())
'This is the override connection string which is set at another place but put here for this example
mConnString = "Data Source=sql04\\dev2014;Initial Catalog=ODInfoCenter_Dev2;Integrated Security=True;Connect Timeout=15;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"
Dim catalogOverwrites As CatalogNameOverwriteHashtable = ODInfocenterCoreDataAccessAdapter.GetCataLogNameOverwriteHashtable(mConnString)
ErrorManager.Info("FindByEmailAsync - Conn:" & mConnString)
Dim filterBucket As New RelationPredicateBucket
Dim expr As IPredicateExpression = New PredicateExpression()
expr.Add(UserFields.Email = email)
filterBucket.PredicateExpression.Add(expr)
Using adapter = New DatabaseSpecific.DataAccessAdapter()
Try
adapter.CatalogNameOverwrites = catalogOverwrites
adapter.FetchEntityCollection(entCol, filterBucket)
Catch ex As Exception
ErrorManager.Exception(ex)
End Try
End Using
If entCol IsNot Nothing AndAlso entCol.Count > 0 Then
Return entCol.Item(0)
End If
Return Nothing
End Function
In startup.cs we set the following at last in Configure:
//LLBLGEN CONFIGURATION **********************************************************
RuntimeConfiguration.AddConnectionString("ConnectionString.SQL Server (SqlClient)",
"Data Source=sql04\\dev2014;Initial Catalog=ODInfoCenter_Dev;Integrated Security=True;Connect Timeout=15;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False");
// Configure the DQE
RuntimeConfiguration.ConfigureDQE<SQLServerDQEConfiguration>(
c => c.SetTraceLevel(TraceLevel.Verbose)
.AddDbProviderFactory(typeof(System.Data.SqlClient.SqlClientFactory))
.SetDefaultCompatibilityLevel(SqlServerCompatibilityLevel.SqlServer2012));
The helper method to construct the CatalogNameOverwriteHashTable:
Public Shared Function GetCataLogNameOverwriteHashtable(conn As String) As SD.LLBLGen.Pro.ORMSupportClasses.CatalogNameOverwriteHashtable
Dim newCatalogName As SD.LLBLGen.Pro.ORMSupportClasses.CatalogNameOverwriteHashtable = New SD.LLBLGen.Pro.ORMSupportClasses.CatalogNameOverwriteHashtable()
Dim connBuilder As New System.Data.SqlClient.SqlConnectionStringBuilder(conn)
'newCatalogName.Add("ODInfoCenter", connBuilder.InitialCatalog)
newCatalogName.Add("ODInfoCenter_Dev", connBuilder.InitialCatalog)
Return newCatalogName
End Function