🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
MDriven Framework – a Model driven framework
This page was created by Alexandra on 2018-02-22. Last edited by Wikiadmin on 2026-07-29.

MDriven Framework is for .NET developers who want to build a model-driven application from an MDriven Designer model while adding strongly typed C# business logic.

What you can build with MDriven Framework

MDriven Framework embeds MDriven Designer in Visual Studio and generates the business-layer code that corresponds to your model. The model is the central definition of your domain: you change the model first, then regenerate or synchronize the derived artifacts.

You can use the compiled result to:

  • Build standalone .NET clients or servers based on the model.
  • Add business-specific logic in C# while retaining access to the types and classes in the model.
  • Use the model and compiled code with CodeDress in MDriven Turnkey.
  • Derive relational database schema and mapping information from the model.

For example, if your model contains an Order class associated with OrderLine, MDriven Framework generates corresponding domain-layer code. You can then write C# against those generated, strongly typed model classes rather than maintaining a separate set of manually defined domain types.

Work model first

Model-driven development means that the model is the source definition for derived application artifacts. Define classes, attributes, and associations in MDriven Designer, then let MDriven Framework derive the domain-layer code and database mapping from that definition.

A typical change follows this sequence:

  1. Open the model in MDriven Designer from Visual Studio.
  2. Change the domain model. For example, add a RequestedDeliveryDate attribute to Order.
  3. Synchronize the generated code so that the domain layer reflects the changed model.
  4. Add or adjust your own C# logic where the business requires behavior beyond the model.
  5. Evolve the database when the changed model requires a schema change.

This model-first workflow keeps the model, generated code, and database schema aligned. For a fuller explanation of the model-driven approach, see Documentation:MDriven Developer's Guide: Model-Driven Development Simplified.

Combine generated code and C#

The generated model code gives your C# code direct, strongly typed access to the classes and types defined in the model. Add handwritten behavior as separate code that complements the generated domain layer, rather than editing generated output.

For example, model an Invoice and its InvoiceLine objects, then add C# behavior that uses those generated types to implement an integration or calculation that belongs in application-specific code. Keep the model definition in MDriven Designer; keep the custom implementation in your code project.

MDriven Framework also supports expressing business-specific rules in OCL (Object Constraint Language) and C#. Use OCL when the rule belongs declaratively in the model, and use C# when you need custom .NET implementation.

Database mapping and evolution

MDriven Framework derives database schema, domain-class code, and mapping information between model classes and database tables. When you change the model, Database Evolution updates the schema toward the schema described by the model while preserving existing data where possible.

For example, after adding RequestedDeliveryDate to Order, evolve the database so the stored representation can hold the new value. Review schema changes as part of your normal development and deployment process, especially when changing or removing existing structures.

The available MDriven Framework information identifies support for SQL Server, PostgreSQL, MySQL, and SQLite. For code and persistence details, see Documentation:Code and Persistence Mapping and Documentation:Evolving Databases with Code.

Framework, Turnkey, and MDrivenServer

Choose the MDriven product component that matches where you want to work:

Component Use it when Example
MDriven Framework You want the MDriven Designer model in Visual Studio and want to write strongly typed C# against generated model types. Add application-specific C# behavior to a generated Order domain class.
MDriven Turnkey You want a model-driven application front end that uses the possibilities of MDriven Designer and Server. Use the compiled Framework result with CodeDress in a Turnkey application.
MDrivenServer You need the server component that receives models, maintains supported databases, and provides server-side behavior for an MDriven system. Deploy a model to a server environment that manages the application data.

MDriven Framework and Turnkey can be used together: Framework provides the generated model-based business layer and C# extension point, while Turnkey can use the compiled result through CodeDress. See Documentation:MDriven Product Line for the product-line overview.

Get started

  1. Set up MDriven Framework and Visual Studio by following Documentation:Framework.
  2. Create a small model with two related classes, such as Customer and Order.
  3. Generate and inspect the domain-layer code in your .NET project.
  4. Add a small C# behavior that uses a generated model type.
  5. Make a model change, synchronize the code, and evolve the database if the change affects persistence.

If you already have a model created outside the Framework workflow, follow Documentation:Moving your work from MDriven Designer to MDriven Framework. For API-level details, see Documentation:Api documentation.

See also

Model-driven approach and generated artifacts

Model-driven approach and generated artifacts

You can use MDriven Framework when you want a model to define domain types and drive the corresponding database and domain-layer code in a .NET application.

In MDriven, the application model is created in MDriven Designer, the UML modeling tool embedded into Visual Studio. The model defines the types and classes used by the application. MDriven Framework derives the database schema, domain-class code, and mapping information between model classes and database tables from that model.

For example, when you add an attribute to a model class, the change can affect the derived domain code and database schema. Database Evolution is the MDriven term for updating the database schema from model changes while preserving existing data.

Keep model logic and custom code together

You can implement business-specific rules in OCL (Object Constraint Language) and C#. MDriven Framework gives C# code access to the types and classes in the model. Generated code uses partial classes, so you can place custom logic in separate files rather than modifying generated files.

For example, model a Customer class in MDriven Designer, use OCL for a model rule, and add a C# method to the corresponding partial class when the rule requires application-specific code.

Choose the application layers you need

MDriven Framework supports model-derived database schema, domain-class code, and persistence mapping. It also includes declarative ViewModel engines for WPF, MVC, Windows Store, Silverlight, ASP.NET, and Windows Forms. Templates can update C# and VB.NET code.

The framework also provides optional domain-layer features, including undo and redo, versioning for specific classes, and declarative actions. Persistence is accessed through PersistenceMapper interfaces; the documented supported databases include SQL Server, Oracle, MySQL, Firebird, Mimer, NexusDB, SQLite, Blackfish, and Sybase.

Area With MDriven Framework Hand-maintained .NET approach
Domain types Define types and classes in the model; use them from C#. Define and maintain the application classes in C#.
Database schema and mapping Derive schema and class-to-table mapping information from the model; evolve the schema when the model changes. Create and maintain the schema, mapping, and their changes as separate development artifacts.
Business-specific code Add OCL rules and C# code alongside the model-derived application structure. Write the rules and supporting application structure in hand-maintained code.
User-interface representation Use declarative ViewModels where a supported ViewModel engine is appropriate. Build and maintain the UI representation directly in the selected UI technology.

This comparison describes how artifacts are maintained; it does not establish a measured productivity, quality, or sustainability outcome for either approach.

Relationship to MDriven products

MDriven Framework is MDriven Designer embedded into Visual Studio and generates business-layer code corresponding to the model. The compiled result can be used with CodeDress in MDriven Turnkey or to build standalone clients and servers. MDriven Server can receive models from MDriven Designer, maintain a supported database, and execute model-defined periodic declarative jobs.

See also