Altova MapForce 2023 Professional Edition

Generating C# code

Home Prev Top Next

You can generate .NET C# code for any mapping or mapping project where all the mapping components are supported in C#. For an overview of components supported in each language, including C#, see Supported features in generated code. Note that MapForce typically issues notification or warning messages whenever you attempt to add components that are not supported in a specific language.


When generating C# code, you can target not only the .NET Framework platform but also the .NET Core 3.1, .NET 5.0, and .NET 6.0 platforms. If you choose the latter, the result is a .NET (Core) cross-platform desktop application that can run on Windows, macOS, and Linux.


Note the following when generating code:


Certain MapForce features are not supported in generated program code. For details, see Supported features in generated code.

You can generate code either from a single mapping design (.mfd), or from a mapping project (.mfp). If you generate code from a single mapping, the resulting application executes the respective mapping transformation. If you generate code from a MapForce project (.mfp) which includes multiple mappings, the resulting application executes in bulk all mappings included in the project.

You can change the general code generation options from the Tools | Options menu, Generation tab. See Code Generator Options.

You can change the name of the generated mapping application and other settings from the File | Mapping settings menu. The default application name is Mapping. See also Changing the Mapping Settings.

For information about handling paths in generated code, see Paths in Various Execution Environments.

If your mapping contains database components, you can view database specific settings by clicking a database component, and then selecting the menu option Component | Properties. See Database Component Settings.

Support for database connections varies by platform and there are connection kinds that are not supported on all platforms. If your mapping connects to a database, choose a database connection that is compatible with the target environment for which you generate code. For details, see Database mappings in various execution environments.


If your mapping uses database components, make sure to create the database connection using database drivers compatible with the platform on which you intend to run the generated program. For example, ADO database connections and some ODBC drivers are not supported on Linux.


A typical C# solution generated by MapForce includes the following:


Solution (.sln) and project (.csproj) files that can be opened in Visual Studio.

Several Altova-signed libraries required by the mapping (all prefixed with Altova).

The main mapping project (in this example, Mapping), which includes the mapping application and dependent files.


Sample C# solution generated with MapForce

© 2016-2022 Altova GmbH