Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Tored
Frequent Visitor

How do I use the enhanced metadata format in C#?

Hello, I would like to automate the DataSet generation (using C#). In this context, I have encountered problems when I create the DataSet in Power BI Service (For more information: Data source information is not found in Power BI service ). For this reason, I am now trying to generate the DataSet within a Power BI file in an open Power BI Desktop instance. In doing so, I am running into an issue with the enhanced metadata format, which is what this thread is about.

 

My situation:

With my C# code, I connect to a PBIX file that is open in Power BI Desktop.
Then I add a new data source and a new table to the DataSet from the PBIX file.
After running the code, the table also appears in Power BI Desktop and I can use it.

 

My problem:
The message pops up (translated from German to English):
"No upgrade to use the enhanced metadata format has been performed for this report. The upgrade is required to make modeling changes."

There is also a button "Perform upgrade for report" and when I press it, my table disappears.

 

image.png

 

My questions:
How can I run such an upgrade (for using the enhanced metadata format) with C# code without my table disappearing afterwards or how do I use the enhanced metadata format in C#?

 

My requirements:
- PPU (Premium Per User) Trial License
- On Premise SQL Server
- Microsoft.AnalysisServices Package

 

My code:

 

 

// Get connection string to PowerBI-File
var connections = PowerBIDesktopUtilities.GetActiveDatasetConnections();
var connectionString = connections[1].ConnectString;

using (Microsoft.AnalysisServices.Tabular.Server server = new Microsoft.AnalysisServices.Tabular.Server())
{
   server.Connect(connectionString);
   var database = server.Databases[0];

   // Adding local SQL Server as data source
   string dataSource = "LocalSQLServer";
   bool expression = database.Model.DataSources.Contains(dataSource);
   if (!expression)
   {
      database.Model.DataSources.Add(new ProviderDataSource()
      {
         //[...]
      });
   }

   // Adding Table
   database.Model.Tables.Add(new Table()
   {
      Name = database.Model.Tables.GetNewName("Individual Customers"),
      Description = "Individual customers (names and email addresses) that purchase Adventure Works Cycles products online.",
      Partitions = {
         //[...]
      },
      Columns =
      { 
         //[...]
      }
   });

   database.Model.RequestRefresh(Microsoft.AnalysisServices.Tabular.RefreshType.Full);
   database.Update(UpdateOptions.ExpandFull);
}

 

 

 

Thanks in advance!

1 REPLY 1
Tored
Frequent Visitor

I have edited my post, which hopefully describes my problem more accurately now.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.