BKStart a conversation ↗

MVC Scaffolding and EF4CodeFirst–A data driven website in under a minute!

Here’s a run through on how to create a data driven web application in under a minute. I’m going to create a simple part tracking system so as to manage the vast amount of helicopter parts lying about my garage. Some parts I’ll never use, some parts are missing little comprising bits. The idea is to deploy the application as part of the club website allowing members to quickly find a part in a hurry for the big upcoming competition.

Let's get started:

  1. Install MVC Scaffolding if you’ve not done so before, go to the package console and type Install-Package MvcScaffolding

  • Create a class for the part

Now type Scaffold Controller PartModel

Here you see that all the views get created, hey and they are even DRY.

If you want to make unit testing easier or support IoC etc you can use the –Repository flag.
If you need to rescaffold then use –Force.

Ok so we’re 50 seconds into this at this stage, and we could just run the application now provided we’ve got sqlexpress installed. However if you don’t we can use the SqlCompact version.

Drop back into the Package Manager Console and

Install-Package EFCodeFirst.SqlServerCompact

That’s it, Q.E.D.