Search code examples
sql-serverssassql-server-2014partitioning

Programatically creating cube partitions within visual studio bi project


I am building an SSAS multidimensional cube where I have to define more than 100 partitions since I am handling a huge volume of data. I want to automate creating these partitions within visual studio.

After searching i found a method to create partitions programmatically using AMO.net and C#, but these will create them directly inside the deployed cube, so when you need to edit anything in the cube within visual studio, it will require deploying the project and overwrite the existing database and remove all defined partitions.

Is there is a way to easily define a lot of partitions within visual studio (analysis project) not the deployed analysis database?


Solution

  • You can perform changes to your cube, and then incorporate the changes into the your Analysis Service Tabular Model using the following steps:

    1. If not set, change your Workspace Retention value to Keep in Memory.
    2. In Visual Studio, right click your Model and select View Code.
    3. Run the code to create partitions on your workspace Cube.
    4. Then from SQL Server Analysis Studio right click your cube and do select Script > Script Database As > Create To > New Query Editor Window.
    5. Copy everything in the "model" property from the generated script.
    6. Paste it to the "model" property in your Model code.
    7. Open Model and process.