RUF MVC5 repositories Framework Generator code generation tool introduction and use

Source: Internet
Author: User

RUF MVC5 repositories Framework Generator code generation tool introduction and use

function Introduction

This project has undergone a major six-year continuous update to the current stage of basic stability

All source code is open source, shared on GitHub Https://github.com/neozhu/MVC5-Scaffolder

The entire project structure, the technical framework is completely based on the http://genericunitofworkandrepositories.codeplex.com/implementation.

The lightweight n-tier architecture, Unit of work and Repository design patterns, and the implementation of the Entity Framework Code-first, are very concise and perfect.

And what I'm doing is customizing development through the Scaffolder Code Generation Wizard that is provided by Visual Studio 2013 the source code needed to generate these data schemas through the entity classes, The use of a large number of repetitive code tools to automate the generation of rapid development while also conducive to standardize the programming habits of developers.

Basic functionality that has been implemented

    1. Additions and deletions of a single entity class are implemented through the Easyui DataGrid
    2. Fields with foreign key keywords defined in the Entity class automatically generate Combox query and edit manipulation controls
    3. The entity class defines a one-to-many, master-slave table structure, the system automatic master-slave table editing operation query page and function
    4. editing features, depending on the field type, validation rules generate different editing modes, such as the date type with Datebox, the number type is used Numberbox, the required validation can be implemented
    5. Query functionality, depending on the type of field to generate different controls to facilitate operation, Datebox,combox
    6. Excel import feature, can only implement simple table import configuration now

Using the wizard
    1. Create a new controller

    1. Select RUF MVC5 repositories Framework Generator

    1. Select the Model,data Context you want to generate

Generate views Option Description

    1. Over write existing pages overwrite existing view
    2. Generate Master-detail Relationship Action and PageView if a foreign key and a pair of n collection types are defined in the entity class, the Operation page of the master-slave relationship and the corresponding controller are automatically generated
    3. Set Form Layout Columns Select Generate Edit Page The fields are arranged in a few columns on one line

    1. Define entity validation rules and Chinese descriptions

    1. Update Database

Here the EntityFramework Code-first mode is used to create the data access class, so when you modify the field property of the entity class the system will be re-updated to the entity database

    1. Open the package Manager Console
    2. Running the add-migration system will generate a script corresponding to the modification
    3. Running the UPDATE-DATABASE–SCRIPT system will update the script to the physical database while producing an SQL script to update your production or other databases

    1. Complete System Build
    2. Required Source code files

Here's the standard MVC N-tier architecture specification code

  1. /controllers/productscontroller.cs (Control Class)
  2. /models/productmetadata.cs (Entity Class)
  3. /repositories/products/productquery.cs (Data access Class)
  4. /repositories/products/productrepository.cs (Data access Class)
  5. /services/products/iproductservice.cs (Business logic Class)
  6. /services/products/productservice.cs (Business logic Class)
  7. /views/products/index.cshtml (view)
  8. /views/products/edit.cshtml (view)
  9. /views/products/editform.cshtml (view)
  10. /views/products/_popupsearch.cshtml(view)
  11. /views/products/create.cshtml (view)

  12. Registration Services

Modify/app_start/unityconfig.cs

Registering the newly generated service class for use, which uses the Unitofwork design pattern to implement dependency injection

    1. Run Tests

The interface to run after compiling successfully is as follows

All additions and deletions are implemented via the Easyui DataGrid

Validation rules that include required fields have been generated

The views generated for a pair of n structures are as follows

The upper part is the main Table operation area, the lower part is the schedule operation area.

Demo screenshot

RUF MVC5 repositories Framework Generator code generation tool introduction and use

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.