Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
Sign up nowGet Fabric certified for FREE! Don't miss your chance! Learn more
I'm using the below code in C# .net with an ADO Connection to create a Semantic Model in the power bi service. This code runs perfectly. However, afterwards even though I can see the model in the workspace the "getbyname" command isn't working. I've tried disconnecting and then reconnecting, disconnect, wait and reconnect to no avail.
Is there a way to refresh the connection or something that would allow me to consistently see the model I have just created?
using (AdomdConnection connection = new AdomdConnection($"DataSource={workspaceConnection};User ID=app:{ApplicationId}@{Tenant};Password={ApplicationSecret};"))
{
// Open the connection
connection.Open();
var command = connection.CreateCommand();
command.CommandText = xmlaScript;
command.ExecuteNonQuery();
}
server.Disconnect();
server = ConnectToPowerBIAsServicePrincipal(workspaceName);
Microsoft.AnalysisServices.Database database = server.Databases.GetByName(newDatabaseName);
Solved! Go to Solution.
Hi, @Don-Bot
Regarding your question, you can try the following code:
using (Microsoft.AnalysisServices.Server server = new Microsoft.AnalysisServices.Server())
{
server.Connect(connectionString);
Microsoft.AnalysisServices.Database database = server.Databases.GetByName("adventureworks");
Microsoft.AnalysisServices.Tabular.Model model = database.Model as Microsoft.AnalysisServices.Tabular.Model;
}
Here's a screenshot of the response:
Here are the relevant links, I hope you find it helpful:
Of course, if you have any new ideas, you are welcome to contact us.
Best Regards,
Leroy Lu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, @Don-Bot
Regarding your question, you can try the following code:
using (Microsoft.AnalysisServices.Server server = new Microsoft.AnalysisServices.Server())
{
server.Connect(connectionString);
Microsoft.AnalysisServices.Database database = server.Databases.GetByName("adventureworks");
Microsoft.AnalysisServices.Tabular.Model model = database.Model as Microsoft.AnalysisServices.Tabular.Model;
}
Here's a screenshot of the response:
Here are the relevant links, I hope you find it helpful:
Of course, if you have any new ideas, you are welcome to contact us.
Best Regards,
Leroy Lu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
Check out the January 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 |
| User | Count |
|---|---|
| 5 | |
| 4 | |
| 3 | |
| 2 | |
| 2 |