Exception when referencing SSAS tabular model in C #

I am trying to automate section updates in Azure Analysis Services via C #. I have installed and referenced the latest 'Microsoft.AnalysisServices ...' collected here:

https://docs.microsoft.com/en-us/azure/analysis-services/analysis-services-data-providers .

Then I have the following code:

using System; using Microsoft.AnalysisServices.Tabular;

    public void Run()
    {
        Server asSrv = new Server();

        try
        {

            asSrv.Connect(ASConnectionString);
            Database db = asSrv.Databases.FindByName("HospoIQTabular");
            Model m = db.Model;

            // only refresh 2017 partitions

            m.Tables["Sales"].Partitions["Sales - Post 2017"].RequestRefresh(RefreshType.Full);
            m.Tables["Payments"].Partitions["Payments - Post 2017"].RequestRefresh(RefreshType.Full);

            db.Model.SaveChanges();     // commit which will execute the refresh

        }
        catch (Exception e)
        {
            OnEventLog(e.Message);
        }
        finally
        {
            asSrv.Disconnect();
            asSrv = null;
        }

    }

      

The server connection and the database itself works great. However, trying to reference "db.Model" throws the following exception:

The value "2" is unexpected for "DataSourceType".

I have looked but cannot find anything in this. Any thoughts?

+3


source to share


2 answers


For me the path that worked was C:\Program Files (x86)\Microsoft SQL Server\140\SDK\Assemblies

but only after reading Andra's comment which sent me in the right direction



+1


source


The problem is similar to the Microsoft.AnalysisServices.Tabular NuGet package (v13)



Fortunately, you can use the NuGet packages listed here: https://docs.microsoft.com/en-us/azure/analysis-services/analysis-services-data-providers

+1


source







All Articles