Skip to content

MIKE+ API quick start

Prerequesites

To use the MIKE+ API an installed MIKE+ with version 2024 update 1 or higher is required. Some API may not work with lower version.

Copy and paste required libraries

From MIKE+ installation folder copy required libraries to a local folder with right access. This is the bare minimum of required libraries:

Table 1 Assemblies which need to be referenced

Assembly
DHI.Amelia.DataModule
DHI.Amelia.DataModule.Interface
DHI.Amelia.GlobalUtility
DHI.Amelia.Infrastructure.Interface
DHI.Amelia.ProjectLoaderPFS
DHI.Amelia.ProjectLoaderPFS.Interface
DHI.Mike.Install

According to your project's needs you might to import more libraries from MIKE+ API but the above ones are sufficient to start.

Create your application

Create your application, e.g. a Windows console application and import the libraries. MIKE+ API is developed with .NET8. Please use the same .NET version.

Create your code

E.g. just for testing create a class with an internal function to open and close a database:

Example to open and close a database

using DHI.Amelia.DataModule.Services.DataSource;
using DHI.Amelia.DataModule.Services.DataTables;
namespace MIKEPlusAPITest
{
    internal static class DbTesting
    {
        internal static void ConnectDb(string sqliteFile)
        {
            var dataSource = BaseDataSource.Create(sqliteFile);
            dataSource.OpenDatabase();
            var dataTables = new DataTableContainer(true) { DataSource = dataSource };
            dataTables.SetActiveModel(dataSource.ActiveModel);
            dataTables.SetEumAppUnitSystem(dataSource.UnitSystemOption);
            dataTables.UndoRedoManager = new AmlUndoRedoManager() { DataTables = dataTables };
            dataTables.OnResetContainer(null, null);
            dataTables.DataSource.CloseDatabase();
            dataTables.Dispose();
        }
    }
}

Execute your code

In case you have created a Windows console application you could test your code from Program.cs. Please be aware that MikeImport.Setup needs to be executed before running any other code based on MIKE+ API.

Example to execute code from Program.cs of Windows console application

using DHI.Mike.Install;
using MIKEPlustAPITest;

// 24 is assembly version for MIKE+ 2026. 23 is for MIKE+ 2025.
MikeImport.Setup(24, MikeProducts.MikePlus);
DbTesting.ConnectDb("path to a local MIKE+ sqlite database");