• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
MVC Scaffolding Made Easy
 

MVC Scaffolding Made Easy

on

  • 4,347 views

- Intro to MVC Scaffolding, CodeFirst, Repository Pattern ...

- Intro to MVC Scaffolding, CodeFirst, Repository Pattern
- Customizing view and Controller Templates
- Using T4 Scafoldering Commandlets
- Packaging Custom Scaffolder
- Customizing Scaffolding Environment


Scaffolding is a way to quickly create an application layout based on data. This means there are less routine tasks that developers need to do, for example, creating your own controllers/views, CRUD methods, and validation, and more time spent on solving business problems. Learn how to customize the scaffolding using T4 templates, so that the generated output suits the needs of your application, in case you need to regenerate the scaffolding occasionally during development.

Statistics

Views

Total Views
4,347
Views on SlideShare
4,346
Embed Views
1

Actions

Likes
1
Downloads
30
Comments
0

1 Embed 1

http://www.docseek.net 1

Accessibility

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • “…it doesn’t generate code that suits my project.”“…the code is not complete enough for Production use.”“…I have a non-MVC project
  • First demo – default MvcScaffolding using diloguesDescribe filesAdd view WorkOrderAdd controler, new data contextDefault dB is SQL express – go lighter using SQL CEPM> Install-Package EntityFramework.SqlServerCompactPM> Install-Package MvcScaffoldingPM> Scaffold Controller –ModelTypeWorkOrder –ControllernameWorkOrderController – DbContextTypeWorkOrderDbcontextMVC controllers best practiceencapsulate something in the interface leverage dependency injection (to make the controllers testable)Let’s add repository PM> Scaffold Controller –ModelTypeWorkOrder –ControllernameWorkOrderController – DbContextTypeWorkOrder – RepositoryPM> Scaffold Controller –ModelTypeWorkOrder –ControllernameWorkOrderController – DbContextTypeWorkOrder – Repository -Force
  • Everything revolves arround command lineImportant to not only understand but also to know what’s availableSwitch = booleans – false by default, it’s pressence implies setting to true (basic Power Shell functionality)Options
  • Get-ModuleGet-Command –Module T4ScaffoldingGet-Alias ScaffoldGet-Help Invoke –Scaffolder (abreviated list, just the basic command options, use TAB to see all the options)Scaffold [tab]Controller –[tab]Scaffold [tab]View –[tab]
  • Customizing templates
  • ScaffoldMvcScaffolding.ActionWithUnitTest –Controller WorkOrderController –Action ArchiveWorkOrder –ViewModelWorkOrderCustomizingScaffold CustomTemplateViewIndexShow the CodeTemlate folder with T4 fileFind ModelProperty and add “DisplayName”Add new method GetDisplayName()PM> Scaffold Controller –ModelTypeWorkOrder –ControllernameWorkOrderController – DbContextTypeWorkOrder – Repository -Force
  • Jay has shown you
  • Jay has shown you

MVC Scaffolding Made Easy MVC Scaffolding Made Easy Presentation Transcript

  • http://geekswithblogs.net/mradradacz.mcp@gmail.com
  • …generate “starter” code……provide a extensibility mechanism to customizegenerated code……generate more than just MVC Controllers andViews…
  • Install-Package MvcScaffoldingScaffold Controller Product
  • Invoke-Scaffolder “Scaffold” Alias scaffoldingTabExpansion (context command line switch)
  • Action • MvcScaffolding.Action Controller • MvcScaffolding.ControllerCustomScaffold • T4Scaffolding.CustomScaffolderCustomTemplate • T4Scaffolding.CustomTemplate DbContext • T4Scaffolding.EFDbContext Repository • T4Scaffolding.EFRepository UnitTest • MvcScaffolding.ActionUnitTest View • MvcScaffolding.RazorView Views • MvcScaffolding.Views
  • Get-DefaultScaffolder ControllerSet-DefaultScaffolder Controller MvcScaffolding.ControllerWithRepository
  • Action:Scaffold Action -Controller TasksController -Action Foo -ViewModel TaskUnit Test:Scaffold UnitTest -Controller TasksController -Action CreateBoth in 1 shot:Scaffold MvcScaffolding.ActionWithUnitTest -Controller TasksController -ActionArchiveTask -ViewModel Task
  • Scaffold CustomTemplate <ScaffolderName> <TemplateName>Scaffold CustomTemplate View Index
  • Add- Add- Add-ClassMember Find-ScaffolderTemplate Get-DefaultScaffolder ClassMemberViaTemplate ProjectItemViaTemplate Get-Get-PluralizedWord Get-PrimaryKey Get-ProjectFolder Get-ProjectItem ProjectAspNetMvcVersionGet-ProjectLanguage Get-ProjectType Get-RelatedEntities Get-Scaffolder Get-SingularizedWord Invoke-Scaffolder Invoke-ScaffoldTemplate Set-DefaultScaffolder Set-IsCheckedOut
  • Whether n00b(ie) or Expert:Scaffolding should be a tool in your toolbox!
  • http://blog.stevensanderson.com/2011/01/13/scaffold-your-aspnet-mvc-3-project-with-the-mvcscaffolding-package/http://mvcscaffolding.codeplex.com/http://webapiscaffolding.codeplex.com/http://geekswithblogs.net/michelotti