Navigation: CodeStencil > Custom Library > Code Nanites > Table Related > GenerateModel |
Expansion Label: |
CS_GENERATE_MODEL |
Dependency: |
CS_TABLE_LIST, CS_TABLE_LISTS |
Description: |
Generate a model. |
This will generate model classes for tables in your Schema
This is what setting up this Code Nanite looks like:
using System; using System.Collections.Generic;
namespace [%NAMESPACE%].Models { [%CS_GENERATE_MODEL%] }
|
This is what the generated code looks like:
using System; using System.Collections.Generic;
namespace MyProject.Models {
public partial class Course : AuditableBaseEntity { public Course() { CourseAssignments = new HashSet<CourseAssignment>(); Enrollments = new HashSet<Enrollment>(); }
public int CourseID { get; set; } public int Credits { get; set; } public string Title { get; set; } public int DepartmentID { get; set; }
public virtual Department Department { get; set; } public virtual ICollection<CourseAssignment> CourseAssignments { get; set; } public virtual ICollection<Enrollment> Enrollments { get; set; }
} } |
The highlighted the code is what is generated and inserted by the CS_GENERATE_MODEL code nanite. Also, it generates code for every table in your schema because in the label of the node ( See Code Tree), we used the [%CS_TABLE_LIST%] Code Nanite.