Thursday, September 6, 2012

How to create a simple CRUD controller using Database First MVC4 and EF 5




How to create a simple CRUD controller using the following:
Visual Studio 2012
Microsoft MVC 4 Framework
Entity Framework EF5
Database First
Create a database called MusicDb
 
Create table Album
(AlbumId int identity(1,1) PRIMARY KEY,
Name varchar(50),
Artist varchar(50))
 
In visual studio, create a new project and select the MVC 4 template (assuming you have your VS configured with MVC4 and EF5)
Adding Model
ADDING A CONTROLLER
Now build and run your project.
It shows default page.
Enter the following after your URL
http://yourURL/Album
You should now be able to add, update and delete albums from your db.


1 comment: