MvcModelGenerator is a plugin package 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.
Contents:
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.
- If you want to add implemented interfaces defined in DSL using Implements DSL concept, add ImplementInMvcModel concept to Implements:
Implements 'MyNamespace.ITheInteface, MyAssembly' { ImplementInMvcModel; }
- 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.
Installing this package to a Rhetos application:
- Add "Rhetos.MvcModelGenerator" NuGet package, available at the NuGet.org on-line gallery.
Contributions are very welcome. The easiest way is to fork this repo, and then make a pull request from your fork. The first time you make a pull request, you may be asked to sign a Contributor Agreement. For more info see How to Contribute on Rhetos wiki.
- Note: This package is already available at the NuGet.org online gallery. You don't need to build it from source in order to use it in your application.
- To build the package from source, run
Clean.bat
,Build.bat
andTest.bat
. - The build output is a NuGet package in the "Install" subfolder.