MvcModelGenerator is a DSL package (a plugin module) for Rhetos development platform. It automatically generates ASP.NET MVC model for all entities and other queryable data structures that are defined in a Rhetos application.
See rhetos.org for more information on Rhetos.
MvcModelGenerator package, when deployed, generates source and binary files in \bin\Generated
folder inside Rhetos server.
Include the generated files in your ASP.NET MVC application (or any other),
for faster GUI development and easier integration with Rhetos application server.
Rhetos.Mvc.cs
contains MVC model classes for Rhetos entities and other data structures.- The generated classes and their properties have standard ComponentModel.DataAnnotations attributes based on CommonConcepts features in DSL scripts: Required, UIHint, MaxLength, MinLength, RegularExpression and Display.
- Custom attributes are also assigned for additional functionality: MaxValue, MinValue, RenderMode and LocalizedDisplayName.
- The generated
Captions.resx
resource file contains default captions (display names) for properties, entities and other data structures. The MVC model classes are bound to the resource file by Display attribute. - Option A: To use the generated captions include
Captions.dll
into your web application. - Option B: Include
Captions.resx
into your web application project. Make sure to set the file's properties in Visual Studio to match the following:- Custom Tool Namespace: Rhetos.Mvc
- Build Action: Embedded Resource (default value)
- Custom Tool: ResXFileCodeGenerator (default value) or PublicResXFileCodeGenerator
- To override default captions, include
Captions.resx
directly into your project (see the instructions above) and add a new resource file with your culture's name (for exampleCaptions.en-GB.resx
orCaptions.hr-HR.resx
, see CurrentCulture). The ASP.NET will automatically use the captions you entered in the culture-specific resource file, or fallback to the default captions if the localized caption is not entered.- Make sure to set the same properties in Visual Studio for the localized resource file as for the default
Captions.resx
file.
- Make sure to set the same properties in Visual Studio for the localized resource file as for the default
- There are free resx editors to help you enter the captions.
- MvcModelGenerator includes CamelCase splitter plugin (CamelCaseCaptions) that splits property names into words when generating default captions, reducing the need to override default captions.
- Similar caption processing plugins may be implemented in a Rhetos package by implementing ICaptionsValuePlugin interface.
- CommonConcepts package must be deployed along with MvcModelGenerator.
- Build utilities in this project are based on relative path to Rhetos repository.
Rhetos source should be downloaded to a folder
with relative path
..\..\Rhetos
and compiled (useBuild.bat
), before this package'sBuild.bat
script is executed.
Sample folder structure:
\ROOT
\Rhetos
\RhetosPackages
\MvcModelGenerator
- Build this package by executing
Build.bat
. The script will pause in case of an error.- The script automatically copies all needed dll files from Rhetos folder and builds the Rhetos.MvcModelGenerator.sln using Visual Studio (command-line).
- Set the new version number in
ChangeVersion.bat
and execute it. - Execute
Build.bat
. - Execute
CreatePackage.bat
. It creates installation package (.zip) in parent directory of MvcModelGenerator.