MVC Architecture


What is MVC?
MVC is a framework like model view controller.
in MVC we should use Entity Framework for database connection
Why we go for MVC?
1.MVC pattern saperates model,view,controller.
2.While developing the application developer can easily work in model,view, controller individually.
3.Easy to testing the applications.
What is Model,View,Controller?
Model:
model is nothing but business logic
simple logic model contains the Database table and database columns are written in model,
i.e  table name is model name and table column name is model properties
Example:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity;
namespace MvcDemo.Models
{
 public class Eemployee
 {
     [Key]
     public int enpid{get;set;}
     public string empname{get;set;}
     public bool isActive{get;set;}
 }
}
public class StudentDbContext:DbContext
{
   public DbSet<Eemployee> employee{get;set;}
}
DbContext:
it is a object context primarily interacting with database using specific model
i.e. the database table names are written in the dbcontext
DbSet:
it is object-Set used to perform the CRUD operations into the specific model
View:
View is nothing but the user interface. this will perform, handles data from model and
display’s into the view.
Controller:
Controller will do, handles the data from Model and Controls the data and displays into view,controls the input data send back to Model

Popular Posts