4

I'm doing my first ASP.NET MVC 3 project here, and since I need to support stored procedures, I decided to use Entity Framework 4.1 with the "database-first" approach, e.g. with all the EDMX goodness.

Since I absolutely need the stored procedure support, I cannot use code-first (as much as I'd love to).

All the cool new MVC scaffolding stuff seems to be based on code-first (which I cannot use - see above) -- or is there a way / a setting to influence it so that it'll use ObjectContext instead of DbContext??.

So how do I create a quickie section of my MVC 3 app to scaffold some lookup tables - using the EF 4.1 database-first approach? Can I use dynamic data? How do I add this to an existing MVC 3 (.NET 4) project?? Can't seem to find any "add new item" entry for dynamic data..... and all the how-to videos I find are for MVC 1 or 2 and .NET 3.5 - do they still apply??

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

3 Answers3

2

Please see this comment at here. I think you should customize the T4 template for your business. And Stev also have a good article at here.

thangchung
  • 2,020
  • 2
  • 17
  • 28
  • 2
    @marc_s Sorry for my fault. I think this is exactly thing you need http://thedatafarm.com/blog/data-access/mvc3-1-scaffolding-magic-with-database-or-model-first-not-just-code-first/ :) – thangchung Aug 18 '11 at 16:14
  • Thanks - that seems to describe exactly what I was looking for, indeed! – marc_s Aug 20 '12 at 08:52
0

Hope you had tried this:

Scaffold Controller Participant -force -repository -DbContextType "DBEntities" 

where DBEntities is the name of model class generated by entity framework.

McGarnagle
  • 101,349
  • 31
  • 229
  • 260
mohit bansal
  • 331
  • 3
  • 7
0

It ended up being impossible to use the built-in scaffoling for ASP.NET MVC 3 without an outrageous amount of extra work - so I ended up going back to ASP.NET Webforms for this little project of mine.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459