Does anyone know of a good/usable ASP.NET MVC code/solution generator. Ideally it would build from a domain model, but from a data model is also acceptable.
If you do, can you answer the following:
If there isn't one you know of then do you think this is something missing from the community or do you not think it is needed? What features would you like to see in one?
Can't wait to hear your answers...
Thanks Scott
S#arp Architecture includes scaffolding generator using T4. It generates model, views, controllers, and tests from the template model definition. You get full CRUD. Since it uses T4 (Visual Studio template language I suppose) you can extend default templates as you want.
Here's an example of the template:
EntityScaffoldingDetails entityScaffoldingDetails =
new EntityScaffoldingDetails("Organization.Worker");
/*
* Property names should be PascalCase.
* Do not include a property for Id as it will be included automatically.
*/
entityScaffoldingDetails.EntityProperties.Add(
new EntityProperty("FirstName", "string", "Joe", "[NotNull, NotEmpty]", true)
);
entityScaffoldingDetails.EntityProperties.Add(
new EntityProperty("LastName", "string", "Smith", "[NotNull, NotEmpty]", true)
);
entityScaffoldingDetails.EntityProperties.Add(
new EntityProperty("BirthDate", "DateTime", DateTime.Parse("1/1/1975"))
);
entityScaffoldingDetails.EntityProperties.Add(
new EntityProperty("Manager", "Employee", null, "[NotNull]")
);
///////////////////////////////////////////////////
// The first parameter should reflect the root directory of your solution
//ScaffoldingGenerator generator = new ScaffoldingGenerator(
//@"D:\Work\Project\", "Orders", entityScaffoldingDetails);
// Uncomment this line when you're ready for the scaffolding generator to fire...be sure to recomment after it completes to avoid accidental generating!
//generator.Run();
One small addition: I would not recommend using it as is, because, for example, I'd prefer controllers to work with ViewModel, not entities. And I don't use scaffolding much. But it is pretty flexible, though you may need to learn T4.
You could try a Visual Studio 2010 extension called Radarc. It has a repository of extensions (called Formulas) which allows you to generate solutions for different architectures and technologies. Using Radarc with MVC Formula you can create ASP.Net MVC 3 applications with EF Code First either from a new domain model or importing an existing database.
I am working in this product team so I am not too objective to reply all your questions, but yes it can be extended.
Have you taken a look at Naked Objects MVC ? at least for academic reasons is very interesting.
The Naked Objects MVC framework will take a Domain model (written as POCOs) and render it as a complete HTML application without the need for writing any user interface code - by means of a small set of generic View and Controller classes. The framework uses reflection rather than code generation. The developer may then choose to create customised Views and/or Controllers, using standard ASP.NET MVC patterns, for use where the generic user interface is not suitable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With