MVC 5 Scaffolding - visual-studio-2013

I am using the mvc5 database first approach on a project.
The project is huge, 170 tables or so in the database.
I was wondering, is there a way to automate the scaffolding of the "MVC 5 Controller with views, using entity Framework" per model?
I am pointing to my own Templates (Create.cs.t4, Delete.cs.t4, Details.cs.t4, Edit.cs.t4) and will be changing them quite often
Obviously going through each item to create the "new scaffolding" will take me hours so i was wondering if there is a way to automate this process?
Is there a command i can call to create all the controller and view scaffolding for all the models i have?

As of right now, there is no out-of-the-box solution to automating the scaffolding like you can create a data model for the whole db at once. This would be a good enhancement request to put in, though. Roll up your sleeves or hire a couple of interns.

Related

Managing Model Changes in ASP.NET MVC Razor Views

I am working on a business application which is being developed from scratch. We have opted to design our business logic using Entity Framework, and since the application has to be delivered on the Web we have selected MVC 3 (Razor) for presentation.
Things are pretty fine yet, but I am afraid how will I manage if anytime in the future we need to change our Entity Classes (like adding/removing fields in the business entities or adding more relational entities etc.). I know I can update my model by selecting "Update Model from Database" in Visual Studio (we are using Database first approach). In this case will I have to scrap my old views and generate new ones or is there any way I can update my exiting views.
That questions a little ambigous, so I'll talk about MVC concepts
The whole approach of MVC is "serperation of concerns" so you should be able to lititimatly change your Model (database, entity Framework, etc.) without updating your controllers or views.
That said your model's responsibillity is to return the data required by the controller/view. So it needs to be consistant. So if you model is bound to a view that return data x, if this view is updated, moved to a new platform, etc, etc then the model should still return the same basic information (for it to continue to work with your existing views/controllers).
If your using code first then you should be able to generate any required db views, etc. on a new db, providing this db supports code first generation (so basically MS-SQL I believe)
When using Editor- or DisplayFor you can pass in the entire model and it will show all the properties on the model.

Creating simple CRUD frontend component in joomla1.5

I am trying to convert a php application to joomla1.5 app. I have read some docs on how to create components in joomla1.5 but however i am lost at the best approach to create a simple CRUD frontend Component.
Here are my few questions
1) Should i perform my CRUD operations using JTable or simply use models and write my insert,update,select and delete scripts in the methods?
2) Where should this table class be placed if JTable
Thanks
Ok, first thing before you get too far is to upgrade to 2.5. There is no point in developing anything for software that is reaching end of life in about 60 days.
Next, anything dealing with the database should be put in the model. In Joomla it should be pretty straight forward, have you ready the MVC tutorial? Start with that, it should clear things up.
http://docs.joomla.org/Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!2.5
Yeah, forget Joomla 1.5 and then use this scaffolding tool

MVC 3, Entity Framework 4.x, Database First, Desperation

VS2010 Pro + SqlServer Express.
Having been dropped into ASP.NET MVC 3 with no guidance but the web (2 books on order), I can't even get off the ground.
The MVC itself I get. Not a problem.
PHP, Ruby, and even ghastly WebForms firmly tucked into my toolbelt, with a long history of C++ QT client-server development before that.
Tying ASP.NET MVC 3 to a database using EF4 ORM is killing me.
The goals:
Use database modeled by DBA. I can specify all naming conventions, but code first is not an option!
Import to EDMX. This will be regularly updated using VS tools from the DBA's DB, never edited directly.
Generate partial classes from EDMX, for use as model. This will regularly be updated using VS tools, never edited directly.
Use 'buddy' to extend above model class with code as the Controllers/Views need.
Intuitively use the resulting model, pass it to the view, retrieve posts into it for insert/save, etc...
I've seen and read so many blogs, forum posts, walkthroughs, and stack overflow posts regarding this very use case.
I even tried riding the magic unicorn, followed by the latest 4.2beta1 with DbContext generators.
But can't get off the ground.
I follow instructions, but just not understanding how to do anything with it.
What conventions does the 'buddy' require (if any)? How do I use it? How do I get data with it? How do I write data?
Every example looks different. MVC guides are always focused on the UI side. EF guides don't cover usage in the MVC.
These are basic questions, and I'm feeling like the most incompetent idiot in the WWW right now.
Is anyone out there currently using MVC3 & EF4.x in the way I describe above?
This video is a good starting resource. Its a video of a guy creating an app from scratch that uses entity and a sql database (though he makes the db in the video, its still good for seeing some basics in action). You can see how he pulls data from the database, displays it on the page, and saves changes back to the database.
The first question I would ask is why are you stuck on using EF as an ORM or even insisting an ORM at all? I'd choose tools to suit the job here, especially given the constraints of the data layer.
Buddy classes were a concept invented in a day when the main .NET ORMs had no code-first option as ORM-encumbered class instances really don't behave well under things like model binding. Nevermind you could not decorate them with the DataAnnotations one used to indicate fields were required. Typically, the technical requirement is to use [MetadataType] attributes to tie your buddies to your models and perhaps something like AutoMapper to map data to and fro.
All that said, as a guy who has a few apps with lots of buddies and lots of automapping going on, you might want to think otherwise -- it is a bit of a maintenance nightmare. I'm living it.
There are some really good getting-started videos and tutorials right on ASP.NET MVC's site. The "Model (Data)" section is Entity Framework focused and touches on hot/trending topics like Repositories and Units Of Work.

mvc3 wizard like pages saving state to a database

With using MVC3, I am hoping for a decent wizard multistep approach. I need to have previous, next , save buttons. Both Next and Save will be saving data to the database (more of holding staging table), yet I don't want to make the navigation a nightmare to code and manage. I use to do this stuff with webforms, but I am hoping for a good solution with mvc3. I really don't want sessions or cookies. I did notice in the Apress book "Pro ASP.NET MVC 2" by Steven Sanderson. On page 478 he says "There are unlimited ways in which you could accomplish this....." (regarding a wizard multistep form).
He mentions collecting and preserving data with Microsoft MVC Futures dll download, and then serializing hidden input tags.
I wanted to hear back from some experts out there on this approach vs. other approaches/solutions.
Thanks in advance.
hope this post will give you some start
You can have a look of the simple component MVCWizard.Wizard available on NuGet. The WizardController allows you to create a wizard using partial view. There is also the AutoWizardController that renders the entire wizard in a single view. All these components operate with the session to store the model state. You can find example of MVCWizard on NuGet.

What new features would you like to see in Asp.net MVC 3?

Asp.net MVC 3 preview 1 was released at the end of last month. Are there any new features you are excited about or any features you would like to see before it is fully released?
Full support for Controllers with Generic Parameters
public GenericController<SomeType> : Controller
Generic controllers are quite possibly the greatest MVC timesaver if your doing a lot or business CRUD. There are so many similarities between the Add methods of almost every MVC project that it makes sense to abstract these operations out in a Controller that fits all scenarios.
Right now its a little hacky to create a generic controller. The MVC engine always gets the name wrong (GenericCo vs. Generic) and without full support plugin and libraries that interact with controllers just fall over when they encounter a generic one.
Make Dropdowns easier to work with
As a professional MVC tag watcher I've noticed that working with dropdowns is one of the most repeated questions on SO. The amount of Dropdown questions is a strong indication that something should be done to make it easier or less ... complex?
make checkbox list easy to work with
add T4MVC to the official release
add official helpers for OData
support one javascript library either MS Ajax or jQuery(preferably)
I wish they can add something to help developer to migrate their previous ASP.NET WebForms application.

Resources