step 1 USE [EmployeeSystem] GO /****** Object: StoredProcedure [dbo].[spAddDepartment] Script Date: 13/02/2018 12:32:38 AM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER Procedure [dbo].[spAddDepartment] @DepartmentName nvarchar(50) as Begin Insert into Departments values(@DepartmentName,1) End
step2 protected override void OnModelCreating(DbModelBuilder modelBuilder) { modelBuilder.Entity<Department>().MapToStoredProcedures ( s => s.Insert(i => i.HasName("spAddDepartment")) ); base.OnModelCreating(modelBuilder); }
public ActionResult Insert(Department depart) { // return View(); hr.Departments.Add(depart); hr.SaveChanges(); return View(depart); }
How to insert data using existing stored procure mvc
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)