M# Tutorials

Learn to build .NET applications with M#. Our step-by-step tutorials will get you up-to-speed rapidly.
If you already know ASP.NET and C#, you can master M# in a week or two.

Entity, Page, Module

This lesson gives a bird’s eye view of the core components of M#. The web application structure in M# heavily depends on components described below, which are discussed in further detail within individual chapters. A developer must understand these components in order to effectively develop and maintain quality web applications in M#.

Entity

An entity represents a real world object, distinguishable from other entities, which exists in a business domain. In M# the same exact definition is undertaken. In M# the first thing a developer needs to do is to build a concrete business domain model, which consists of entities often referred to as business objects.

M# intelligently converts an Entity Domain Model, with all the associations and relationships, into database tables while maintaining entity relationships. This eliminates the need of developing Database and Business entities separately, significantly reducing the development time.

M# fully supports Object Oriented development and encourages developers to use all such features exposed at entity and property level.

Adding New Entity

A new entity can be added by using the “+” sign / button available on each namespace as shown below

Name

The Name of the Entity

Note: Always use singular naming convention when creating entities. M# intelligently uses plural naming convention where and when required.

For example: creating the entity shown in above image, M# creates a visual studio class with the name of “Member”, also creating a database table using the plural “Members”.

Note:When adding entity names use normal English language style (i.e. with spaces and normal character case). M# automatically creates the class and database table according to standard naming conventions.

For example: creating an entity name as “Hello world entity” will be converted to “HelloWorldEntity” entity name and “HelloWorldEntities” database table name. Same applies to Properties.

Base Type

This property is used when a developer wants to inherit an existing entity type. M# creates a Member entity, which inherits from the “User” entity and also creates “dbo.Members” database table with one to one association on “dbo.Users” database table. This property is also available while editing the entity structure.

Namespace

The logical separation within the model and can be changed. This doesn’t have any impact on the business logic namespace in the visual studio project or the database. It is just a logical separation within M# to categorise entities in related groups.

Database Mode

This is a very important property, because it defines the nature of the entity being created. This property has four options, as outlined below.

Managed

M# uses this option by default. Under this option, M# creates a database table for the entity and assumes that this entity will hold real data.

Transient

This option is used mostly to develop “Interfaces” for the Domain Model. M# doesn’t create any database table for the entity.

Custom

Select this option when an entity represents an external database table.

Existing

When you have an existing database, but want M# to generate an ADO.NET data accessor for it.

Managing Entity

Select entity from the Model section

A context menu will be displayed

Use the context menu to alter the Entity level settings

Deleting an Entity

M# provides the delete option under “References” tab of the top menu as shown below.

Note: You must delete all the properties of the entity before deleting the actual entity.

Pages

Pages are fundamental for any web application and are required to display content on the website. M# provides this feature under the User Interface Section, within M# UI. Pages created here are placed under “Pages” folder of the Visual Studio’s Web Application Project. M# generates a default “Login” page when a project is created.

Creating New Pages

A new page is created either using “Create Page” link-button or by clicking on any existing “Webpage Icon”. M# allows developers to create Root or Subpages as required in application structure.

Create Root and Subpages

On selecting either of the option mentioned above, M# provider further options to customise the page.

The picture above shows the following settings for each page:

Name

This option allows the developer to specify the name of the page. This option works as the title and actual name of the page. Page names with white spaces are assembled using SEO standards e.g. A page name “Hello world” will have a URL “Hello-world.aspx”

Parent

This option allows the developer to specify the parent page. If a parent page is specified then M# creates the page as a subpage, if left empty M# creates it as a root page.

Master Pages

This option lists all the Master pages available for the current project. There is no restriction on choosing different master pages for nested or root pages.

 

Creating CRUD pages

M# provides a very easy way to create CRUD pages. M# creates two pages when this option is selected.

First to display a list of records with “Edit and Delete” options also refered to as “List Page”

Second to enter “New Records” or “Edit” existing also refered to “Form Page”

The picture below demonstrates, how to create CRUD pages in M#

Entity Type

This is a mandatory field, which lists all the available Entities within the Project. The selected entity is used to create the CRUD pages.

Add to Menu

This option lists all available menu modules and allows the developer to select a menu, which will hold the navigation to this page. A menu in M# is a special module which holds navigation to the pages within the website. Menus are discussed later in this chapter. This field is not mandatory.

List Master Page

This option is used to specify a “Master Page” for the “List page”. This option is mandatory.

Form Master Page

This Option is used to specify a “Master Page” for the “From page”. This option is also mandatory.

View Master Page

This Option is used to specify a “Master Page” for the “view page”. This option is not mandatory.

Modules

M# generates ASP.NET User Control ascx called “Module”, which is placed in the “Modules” folder within “Website” project. M# uses HTML div design pattern to layout modules. M# allows developers to create as many modules as necessary on Model Entities, or special type modules like menus or generic.

Modules encapsulate the actual operation of any page in M#. Module types include forms, lists, menus or simple data views. Each module is developed based on an Entity Type.

Add a New or Existing Module

Click below the listed modules on the page.

Begin writing the type of module i.e. Form, View, List or Menu

Then, specify the name of Entity Type.

M# displays a list of existing modules based on the specified entity with an option to create a new module.

Select the required existing or new module template and press enter or mouse click.

M# lists the selected module and allows you to perform further actions.

M# provides another time saving functionality to ease the process of resuing existing modules in other pages. Just select the module you want to copy and hit “Ctrl + C”. Select the target page where you want to add the module and hit “Ctrl+V”. M# seamlessly copies the entire module to the target page.