In a Azure Function I have connect to the power bi service and can get a dataset by using the FindByName or GetByName but the Database.Model value is null. Which means i cannot refresh the dataset or update anything.
While debugging can see all of the datasets in the workspace. any help gratefully recevie. thanks
using (Server as_server = new Microsoft.AnalysisServices.Tabular.Server())
{
as_server.Connect(connectionString);
Microsoft.AnalysisServices.Tabular.Database db = as_server.Databases.FindByName(database);
Model m = db.Model;
//my model m is allways null pointless to go on
}
I am using Microsoft.AnalysisServices.AdomdClient.NetCore.retail.amd64 19.9.0.1-Preview and Microsoft.AnalysisServices.NetCore.retail.amd64 19.9.0.1-Preview
ok i have also had the pain of trying to get this to work in .net core with little documentation, i have no idea why the below works but here is the code to get a tabular model
note that
database.Model
is null when you inspect it and if you use it directly likedatabase.Model.Tables
you get Object reference not set to an instance of an object for database.Model.gethowever if you cast it, as i did in the last line of code suddenly is works!