Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
I am currently working on utilizing XMLA Endpoint with C# to copy a datamodel that exists in my workspace.
The steps I am following are:
Can someone direct me to how I can resolve this? Or do I need to recreate the entire model in code other than copy it?
My goal is to have a template datamodel that I will copy to different workspaces and then modify them from there.
I have been working with the below code:
const string connectString = "powerbi://api.powerbi.com/v1.0/myorg/MYDATAMODEL";
static void Main(string[] args) {
Server server = new Server();
server.Connect(connectString);
Model model = server.Databases[0].Model;
string sourceDatabaseName = "DATABASE";
string DatabaseName = "DATABASE - Copy";
Database sourceDatabase = server.Databases.GetByName(sourceDatabaseName);
string newDatabaseName = server.Databases.GetNewName(DatabaseName);
Database targetDatabase = CreateDatabase(newDatabaseName);
sourceDatabase.Model.CopyTo(targetDatabase.Model);
targetDatabase.Model.SaveChanges();
targetDatabase.Model.RequestRefresh(RefreshType.Full);
targetDatabase.Model.SaveChanges();
Database CreateDatabase(string DatabaseName)
{
string newDatabaseName = server.Databases.GetNewName(DatabaseName);
var database = new Database()
{
Name = newDatabaseName,
ID = newDatabaseName,
CompatibilityLevel = 1520,
StorageEngineUsed = Microsoft.AnalysisServices.StorageEngineUsed.TabularMetadata,
Model = new Model()
{
Name = DatabaseName + "-Model",
Description = "A Demo Tabular data model with 1520 compatibility level."
}
};
server.Databases.Add(database);
database.Update(Microsoft.AnalysisServices.UpdateOptions.ExpandFull);
return database;
}
}
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |