Creating ASP.NET MVC 5 Application using Entity Framework 6 and Identity with CRUD Operations on visual studio 2015 Part-6


This is the part-6 of asp.net mvc 5 series using entity framework and identity from scratch.What is model and view model ?How we add a reference of one project to another project? Other part of series,
  1. Creating ASP.NET MVC 5 project Part-1?
  2. Creating SQL Server database Part-2?
  3. Creating Entity Framework project Part-3 ?
  4. Customize the default template of ASP.NET MVC 5 Part-4 ?
  5. How to add a controller and view Part-5 ?
  6. How to Add Model Part-6 ?
  7. How to make a patient registration form Part-7?
  1. How to add a Model?

    1. Model is a logical part of application which communicate with the database entities.Our model is already created which is database entity model or entity framework model now we are just creating a RegistrationViewModel class which contains the initialization of database entities model.View Model (just like a class) is created because when multiple entities are used in a single view then we bind the view with view model.For example in patient registration page/form we want to display the patient list also then we need two things, one is patient object initialization and other is patient list.So these two patient and patient list objects are initialized in the view model and we tightly bind the view with view model.First create a model class or (view model class) by right clicking on the model folder and go to Add > Class.
    2. Pop-up window will appear, just select the Class and the enter the name of class RgistrationViewModel.cs and click Add button.
    3. Your RegistrationViewModel class is created.e.g
    4. Now initialize the patient entity model from the entity framework model namespace  or [HIMS.Model].So we are first adding a reference of HIMS.Model project to HIMS.Patient.Registration project.
    5. Pop-up window will appear and under Projects > Solution  check HIMS.Model project and click OK.
    6. HIMS.Model project reference is added to your project.Now include the namespace of HIMS.Model (using HIMS.Model) to RegistrationViewModel class and initialize the patient object by get and set property.

    7. In the next post we will make a patient registration form tightly bound with the RegistrationViewModel using razor engine. If you have any query the regarding the asp.net mvc, please feel free and post a comment right blow. Thank you   

No comments:

Post a Comment

Creating ASP.NET MVC 5 Application using Entity Framework 6 and Identity with CRUD Operations on visual studio 2015 Part-9

This is the part-9 of asp.net mvc 5 series using entity framework and identity from scratch.In this tutorial you will learn how to bind a...