Forum Discussion
Creating a Semantic Model via TOM with ODBC Connections
Hi diegoervitiq ,
Thank you for providing detailed explaination for your query.
Mybe you can try to split the operations into two transactions.
do not add data source and refresh the model in the same transaction.
Add the data source and save the model.In a seperate operation, request for refersh.
model.RequestRefresh(RefreshType.Full);
model.SaveChanges();
This separation ensures that the credentials are properly registered before a refresh is attempted.
ODBC sources often fail when using workspace identity authentication. Instead, use explicit credentials or service principal authentication.
Consider using Power Query (M Expressions) for Import Mode.
Load data from sources like Snowflake or PostgreSQL. This method is more reliable in Premium workspaces.
Hope this helps!
- diegoervitiq10 months agoRegular Visitor
Hi v-sdhruv, thank you for your response.
I’ve tried to separate operations in several ways, but I still get the same error. Here’s my current workflow:
DatasetManager.ConnectToPowerBIAsUser(); Database database = DatasetManager.CreateDatabase(DatabaseName, DatabasesInfo); string databaseNewName = database.Name; DatasetManager.CreateModel(database, ModelFilePath, databaseNewName); database.Model.SaveChanges(); var dbReloaded = DatasetManager.server.Databases.GetByName(databaseNewName); dbReloaded.Model.RequestRefresh(RefreshType.Full); //here crashes dbReloaded.Model.SaveChanges();I’ve even tried adding delays between operations, but it doesn’t help.
How can I properly separate transactions if it’s not done this way?