How to auto-generate simple CRUD controllers and views in ASP.Net MVC 2 (VS2010) Entity Framework project? - asp.net-mvc-2

I have a standard template "ASP.NET MVC 2 Web application" solution, an empty (meaning no data inserted, but with all tables etc. ready and waiting) SQL Server database, an Entity Framework 4 model (edmx). Is there a way to generate simple CRUD controllers and form views for all the entities in the model?

A buddy out there helped me with the answer - the answer is to use a "ASP.NET Dynamic Data Entities Web Application" instead of "ASP.NET MVC 2 Web Application" project template. The rest is 1-2-3-easy and is explained here: http://msdn.microsoft.com/en-us/library/cc488469.aspx

Hmm. His question was how to do this with MVC, not .NET.
I too would like to hook up and generate MVC user forms from a Sql Server schema.

Related

Using WebApi + Odata on an Edmx

We are currently looking at converting from WCF Data Services to WebApi with Odata. Our entity model is defined using an entity framework defined as an edmx. Im struggling to get the edmx working with WebApi OData due to relationships and complex properties.
I'm just wondering whether someone has successfully implemented webAPI with odata on a bigger sized edmx (that has relationships as well)? Any advice would be great.
You may try using RESTier -- a .Net framework built upon Web API OData. There are several things you may need to pay attention:
RESTier has an EF provider which is quite similar with WCF data services. So it should work wiht the edmx model with little tweak.
RESTier is not a "competitor" for Web API OData, it's built upon Web API OData and can fallback to Web API OData.
RESTier currently is a preview version, but it has good support for the common features used of OData service.
If you tried out and find it cannot work, you can create an issues on https://github.com/odata/restier/issues with more detailed information, if you successfully make it work, it will be great you share your experience.

State management techniques ASP .NET MVC 2

I am new to ASP.NET MVC and have worked in ASP.NET before. I am starting a new project in ASP.NET MVC 2 and wanted to find out what all state management techniques are available in ASP.NET MVC 2.
Can anyone please suggest some good resource.
Thanks.
You can use Session just as in ASP.NET WebForms. Was there anything else you wondered? You don't have ViewState as in WebForms, but you can use ViewDatato pass data between controllers and views (see e.g. http://msdn.microsoft.com/en-us/library/dd394711.aspx). What kind of state are you planning to manage?
For state management you can use Session, but to do it the MVC way, you should combine it with action filters.
Here are some links that can help you:
ASP.NET MVC Filters and Statefulness
mvcConf 2 - Brad Wilson: Advanced MVC 3

asp.net mvc page lifecycle event

Currently we are migrating an existing asp.net web application to asp.net mvc 2 platform. All of our pages performs some business functionality before loading the page or initializing the page. How to achieve this similar behavior in asp.net mvc
The logic which we have currently in pagebase class for web app like this..
if (!Page.IsPostBack)
// Presenter.PerformStartUp()
Please help.
Thanks
Subu
ASP.NET MVC is a totally different pattern than what you might have been used in classic WebForms. There are no events in MVC. The are no pages in MVC. There is notion of PostBack in MVC. There is no ViewState in MVC. There are no server side controls in MVC.
In MVC you have a Controller which receives the user request, it manipulates the Model and passes a view model to the View for displaying. A good starting point is here: http://asp.net/mvc
If the existing application you are trying to migrate has been written properly and it has a service layer and a data access layer at best you could reuse those parts into the new ASP.NET MVC application.
In asp.net mvc you create ActionResult methods by decorating them with the attribute [HttpPost] and [HttpGet](HttpGet is default) this is what sepparates between a Get and Post.

MVC3 app architecture - how to store data

Goals:
Be able to rapidly develop an application in MVC3
Have validation in one place (ie probabaly the model)
where I already have a database
Question: What is your current toolchain of choice for this?
I've spiked out:
MvcScaffolding - http://blog.stevensanderson.com/2011/01/13/scaffold-your-aspnet-mvc-3-project-with-the-mvcscaffolding-package/
However this needs EF CTP5 if you use a model first strategy
Couldn't figure out how to get Validation (DataAnnotations) easily from the model eg a [Required] field
EF Model First - again DataAnnotations seemed hard. Entity Framework - DataAnnotations
LightSpeed - http://www.mindscapehq.com/ Current ORM of choice.
Here's my toolchain:
ASP.NET MVC 3 with Razor for the UI part
NHibernate with FluentNHibernate for data access
FluentValidation.NET for validation rules
AutoMapper for mapping between the business models and the view models
MVContrib
I also built a sample project structure using those frameworks.

Is it possible to have a dynamic data ASP.net web application using Entity Framework?

Is it possible to have a dynamic data ASP.net web application using Entity Framework?
ASP.NET Dynamic Data Entities Web Application, this is how it is called in menu (VS2010 and VS2008).
File->New->Project...->Visual C#->Web