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.

Inheritance

Inheritance is one of the fundamental concepts of Object-Oriented Programming. In this lesson we will discuss how inheritance is maintained by M# in business logic and relationships between SQL database tables.

Implementing Inheritance in M#

M# allows developers to select ”Base Class” for the entity while creating or modifying the business entity. We will take the example of our “HelloWorld” project and will develop a new entity called “Employee” which will derive from the base entity “User”.

steps

Add a new entity “Employee” using M#’s model management as shown below. (For more info: please read lesson 3 Entity, Page, Module of chapter 1.)

After creating the entity, you will notice that M# creates a new entity “Employee” which has already two properties “Email and Password” under “Inherited” tab, as shown below:

Generated Code in Visual Studio

M# generates the derived entity class by inheriting the “User” entity:

For more information on entity and partial classes: please read lesson 3 Entity, Page, Module of chapter 1.

SQL Database Structure

For any data driven application, it is very important to have a normalized database. This not only helps to increase performance but also makes it more manageable and saleable. M#’s intelligent database generation engine utilizes best practices to normalize databases and generate relationships among data tables.

Continuing aforementioned example, M# creates a new table called “Employees” in the database and creates a “One-to-One” relationship between “Users” and “Employees” tables. The “Employees” table only, contains a “foreign Key” to “Users” table, as shown in below pictures:

Users database table Empoyees database table Users and Employees One-To-One relationship