Live Demo


EntityUi is a framework, so you have to understand and follow some rules. There are some Core classes available in EntityUi that you have to inherit from.

  • DomainModelBase - Base class that your Domain Model (or really Data Model) objects need to inherit from.
  • ViewModelBase - Base class that your View Model objects need to inherit from.
  • ControllerBase - Base class for your Controller, it provides Crud methods built in.
  • RepositoryBase - Base class for your Repository, it provides Crud methods built in using Entity Framework.

For this demo, we'll use Data Model sample from this Asp .Net tutorial


Let's start with the Student Data Model first.

public class Student : DomainModelBase
{
  public string FirstName { get; set; }
  public string LastName { get; set; }
  public DateTime EnrollmentDate { get; set; }

  public virtual ICollection
  Enrollments { get; set; }
}


It's a pretty straight forward, simple Data Model Class. Notice that were inheriting from DomainModelBase (Id is a property of DomainModelBase).


Next we'll write the View Model Class

public class StudentModel : ViewModelBase
{
  [Required]
  [HelpTip("First Name")]
  public string FirstName { get; set; }
  public string LastName { get; set; }
  public DateTime EnrollmentDate { get; set; }
}


Again, the example View Model is also a very basic class, with some attributes as example. Notice that were inheriting from ViewModelBase.


Well, thats not completely it, but it's close. Next we need the Repository and Controller.

public class StudentRepository : RepositoryBase<Student, YourDataContext>
{
  protected override YourDataContext GetContext()
  {
    return new YourDataContext();
  }
}


public class StudentController : ControllerBase<Student, StudentModel, YourDataContext>
{
  public StudentController()
  {
    Repository = new StudentRepository();
  }
}


And that's pretty much it. Note that all Repository and Controllers for any other Model you add will look exactly the same. You can easily add any method in each if you need to.

Also, please make sure you follow best practices, and put the Data Model in it's own project, Repository and Data Context in it's own project, and the View Model and Controller in the Web Project.


Besides this very basic example, you can easily handle several advanced scenarios also. Some examples are:
  • Use Drop Down Lists
  • Use Master/Child Grid
  • Use Knockout to manipulate the View, for example show/hide fields on toggle
  • Write custom Mapping for objects where Data and View models are not identical
  • And much more...


See the above example in action by clicking below:

Manage Students - Uses standard MVC actions and redirects to Edit/Create/Delete actions.

Manage Students - Uses Ajax to load Edit/Create forms dynamically in a Modal on the same page, and does not redirect the page.

If there is no data, click here to reset it.


.Net Report Builder

Would you like to add Ad hoc Reporting to your Solution? Check out .Net Report Builder, a simple solution that allows programmers to easily add Reporting functionality to their ASP .NET Web Application