🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
Switching to Visual Studio from MDrivenDesigner
This page was created by Wikiadmin on 2026-07-29. Last edited by Wikiadmin on 2026-07-29.

You can move an existing MDriven Designer model into Visual Studio to generate C# code, add CodeDress code, and upload the compiled assembly for use by MDrivenServer.

Choose the Visual Studio project path

Choose the project type that matches the runtime you will use.

Runtime target Start with Notes
.NET Framework 4.7 or later The MDrivenEcoSpaceAndModelProject Visual Studio template Update or install the NuGet packages required by the template before building.
.NET 6 or later A .NET console application targeting .NET 6 or later Install the MDriven.MVC.Core NuGet package. Follow HowTos:How To Create a .NET Core MDriven Project for the current .NET project setup.

To create and run a new Framework-based project rather than move an existing model, see HowTos:First MDriven Framework project. For local MDriven Turnkey server development and debugging, use HowTos:Development in Visual Studio instead; that workflow has additional Turnkey setup steps.

Before you start

Make a copy or backup of the model before changing project formats. You need:

  • Visual Studio with the MDriven Framework extension installed for your Visual Studio version. The extension lets Visual Studio open the model as a model surface and provides code generation.
  • Your existing MDriven Designer model. A .modlr file is used for import into an existing template model.
  • The model's <modelname>_AssetsTK folder. This folder must travel with the model when you use CodeDress.

If MDriven project templates are missing in Visual Studio, see Documentation:Visual Studio Templates.

Move a Designer model to a .NET Framework template

Use these steps when you start with the MDrivenEcoSpaceAndModelProject template.

  1. Start Visual Studio and create a project from the MDrivenEcoSpaceAndModelProject template.
  2. In the created project, remove the template's EcoSpace and PMP items because you are replacing the template model with your own model.
  3. Open the project's .ecomdl model file.
  4. Delete the template model content: classes, views, and actions.
  5. If your existing model is still an .ecomdl file, open it in MDriven Designer and use File → Save As to save a .modlr version. This creates the file needed for the import step.
  6. In Visual Studio, with the target .ecomdl model open, select MDriven → Import modlr and select your .modlr file.
  7. Ensure that <modelname>_AssetsTK is in the project at the same folder level as the .ecomdl file. Add or copy the folder if it is not already present.
  8. For .NET Framework 4.7 or later, install or update the project's MDriven NuGet packages as required by the template.
  9. Build the project. Resolve all build errors before you generate or upload code.
  10. Run Codegen for the model to generate C# code for the model classes.

Example project layout

If the model file is named Sales.ecomdl, keep the associated assets folder beside it:

MyProject/
  Sales.ecomdl
  Sales_AssetsTK/

Do not place Sales_AssetsTK in an unrelated folder. MDriven uses the Assets_TK folder when uploading assemblies for CodeDress.

Move a Designer model to a .NET 6+ project

For .NET 6 or later, create a .NET console application and target .NET 6 or a later version. Install MDriven.MVC.Core, then save the Designer model as an expanded .ecomdl file using File → Save As and copy it, together with its related files, into the project.

Place the model's _AssetsTK folder at the same folder level as the .ecomdl file. Open the model in Visual Studio, run Codegen, and build the solution without errors before upload.

For the complete .NET setup procedure, including prerequisites, see HowTos:How To Create a .NET Core MDriven Project.

Work from Visual Studio after the move

After moving the model, use Visual Studio as the working location for model changes, code generation, build, and upload.

  1. Change the model in Visual Studio.
  2. Run Codegen whenever a change affects model structure. Structural changes include classes, associations, and state machines.
  3. Build the project. You can use F5 to build and start the project when that is appropriate for your project configuration.
  4. Upload only after a successful build. MDrivenServer uses the latest compiled assembly for CodeDress, so an upload without rebuilding can leave the server using older code.

Add C# code with CodeDress

CodeDress lets you complement model code with C#. For example, when you add a method to a class and leave its Body (EAL) field empty, code generation creates a C# method stub. You can implement the method in C# and use the complete model from that code, including logic supplied by referenced assemblies or NuGet packages.

Keep model logic in the model where it benefits from MDriven analysis. Use OCL expressions for derivations and other logic that MDriven can inspect, cross-reference, and use for look-ahead behavior. Use C# through CodeDress when the logic needs capabilities outside the model, such as code from a third-party assembly.

Need Prefer Example
A model-visible derivation that MDriven should inspect OCL in the model A derived value expressed from properties and associations in the model.
An implementation that calls code from a referenced assembly or NuGet package C# through CodeDress A generated C# stub that calls functionality supplied by a third-party library.

Troubleshooting model opening

If an .ecomdl file opens as XML instead of as a model surface, first confirm that the MDriven Framework extension is installed for the Visual Studio version you use. Then check the project file entry for the model. Remove the <SubType>Designer</SubType> element if Visual Studio has added it; the model entry should be:

<None Include="yourmodel.ecomdl" />

You can also right-click the model file in Solution Explorer, select Open With..., select Modlr files (Default), and select OK. See Documentation:Visual Studio and HowTos:Fix Visual Studio Not Opening Model File for details.

See also