Tutorial 1: c#, f.y.i.: errors in the first ASP.NET MVC tutorial ... Creating a Movie Database Application with ASP.NET MVC (C#)


Creating a Movie Database Application with ASP.NET MVC (C#)   http://www.asp.net/learn/mvc/tutorial-21-cs.aspx

Error 1 The type or namespace name 'MoviesDBEntities' could not be found (are you missing a using directive or an assembly reference?)
            C:\ ...  \Controllers\HomeController.cs 13 17 MovieApp
 

Solution:       add                                 using MovieApp.Models;

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Ajax;
using MovieApp.Models;

namespace MovieApp.Controllers
{
    public class HomeController : Controller
    {
        private MoviesDBEntities _db = new MoviesDBEntities();
 


regards,
Gerry (Lowry)

Note:  the tutorials do need to be cleaned up.  Tutorials are for learning not for debugging!

Gerry Lowry, Principal
Ability Business Computer Services ~~ Because it's your Business, our Experience Counts!
68 John W. Taylor Avenue
Alliston · Ontario · Canada · L9R 0E1 · gerry.lowry@abilitybusinesscomputerservices.com
0
gerrylowry
3/24/2009 5:40:20 PM
asp.net.mvc 4300 articles. 0 followers. Follow

20 Replies
2051 Views

Similar Articles

[PageSpeed] 37

This was changed for RTM, I sent mail to the author of the tutorial and we will get it updated.

 

thanks for the catch,

joecar

0
joecar
3/24/2009 5:47:07 PM

 check the name of your entity in your edmx file

0
GillouX
3/24/2009 5:48:33 PM

@ GillouX  ....hi, I am not sure what you are saying ... the solution was to add the using statement.

                   joecar says RTM broke the tutorial ... although I do not understand why/how (joecar   ???).

    GillouX, could you clarify please and thank you.

g.


Gerry Lowry, Principal
Ability Business Computer Services ~~ Because it's your Business, our Experience Counts!
68 John W. Taylor Avenue
Alliston · Ontario · Canada · L9R 0E1 · gerry.lowry@abilitybusinesscomputerservices.com
0
gerrylowry
3/24/2009 6:02:24 PM

 I mean the using statement just make avaiable the library under ...Models namespace.

 your edmx file is so in the model template

if it's the case; there is no reason it shouldn't work except if your entity doesn't not have the same name but I don't think it's your problem anyway :D

0
GillouX
3/24/2009 6:09:59 PM

@ joecar ....... Joe, you are welcome.  Here's another problem with this tutorial:

Stephen Walther, above Figure 13 claims:

          Notice that you get form validation automatically.
          If you neglect to enter a release date for a movie, or you enter an invalid release date,
          then the form is redisplayed and the release date field is highlighted.

This above claim is misleading.

         Id                    int                    No Nulls
        Title                 nvarchar(100)     No Nulls
         Director           nvarchar(100)     No Nulls
         DateReleased  datetime           No Nulls

Examples of validation that is not automatic:
   -- it is possible to enter only a date
   -- it is possible to enter duplicate records

Since it is clearly a tutorial and since tutorials are for teaching,
it should assume the person working through the tutorial is not
Stephen Walther.  Therefore it should say WHAT kind of automatic
validations are possible, how to enable various kinds of automatic
validations, and how to code standard non-automatic validations
such as director must be non blank and movie title must be non blank.

The tutorial concludes "I hope that you discovered that building an
ASP.NET MVC web application is very similar to the experience
of building an Active Server Pages or ASP.NET application."  It's
not.  Building an ASP.NET WebForms with code behind is very
different.  The paradigms are different.

Regards,
Gerry (Lowry)


Gerry Lowry, Principal
Ability Business Computer Services ~~ Because it's your Business, our Experience Counts!
68 John W. Taylor Avenue
Alliston · Ontario · Canada · L9R 0E1 · gerry.lowry@abilitybusinesscomputerservices.com
0
gerrylowry
3/25/2009 6:53:05 AM

 I am very much in agreement with you here Gerry.

If Linq to SQL can map your tables and columns so well then surely the MVC platform should be able to tell that a column/property has a NOT NULL attribute.

Therefore if you have a string column that is marked as NOT NULL why do we have to add our own  RuleViolation class to check that this property is not empty and not null, this should be built in.

0
j
3/25/2009 10:50:41 AM

Yes, there are at least two issues here.

(1) the tutorials need to be improved such that

     (a) they work and they work as intended by the designers with the RTM and

     (b) the tutorials also help the learner understand the boundaries of ASP.NET MVC v1.0.

(2) small and frequent bug free incremental releases precede  ASP.NET MVC v1.0

     example:
       
ASP.NET MVC v1.01 ~~ recognizes NOT NULL column/property;
                                             generates appropriate validation edits automatically
                                        ~~ [optionally] prevents duplicate records

Features like the optional prevention of duplicate records could be controlled
via [attribute] usage. 

regards ~~ gerry (lowry)


Gerry Lowry, Principal
Ability Business Computer Services ~~ Because it's your Business, our Experience Counts!
68 John W. Taylor Avenue
Alliston · Ontario · Canada · L9R 0E1 · gerry.lowry@abilitybusinesscomputerservices.com
0
gerrylowry
3/25/2009 12:55:01 PM

 Agreed, however is this a developer led community? Do MS read these forums and add the requests to new releases? Is it worth setting up a new thread with ASP.NET MVC 1.01 requests

One other issue I have is with ValidationMessage, there should be an overload method that allows option of message appearing in a ValidationSummary

0
j
3/25/2009 1:10:17 PM

Yes, Microsoft has people assigned to these forums AFAIK.

I also imagine that the ASP.NET MVC team members also lurk here too.

Microsoft people examples:  joecar, ricka6levib, and jeloff are ASP.NET team members.

I've seen occasional postings by Phil Haack and Scott Guthrie too.

There are also MVPs who likely are an audience that has access to Microsoft's "ear".

Regards,
Gerry (Lowry)


Gerry Lowry, Principal
Ability Business Computer Services ~~ Because it's your Business, our Experience Counts!
68 John W. Taylor Avenue
Alliston · Ontario · Canada · L9R 0E1 · gerry.lowry@abilitybusinesscomputerservices.com
0
gerrylowry
3/25/2009 1:28:12 PM

 Is it worth setting up a request thread with strict rules where people cannot comment they just put their requests in and then the MVC team can decide what they want to include?

0
j
3/25/2009 1:36:58 PM

As long as Microsoft is following the ASP.NET MVC forum, I think individual
posts on issues as part of the forum is a better approach.  That way there
will be debate and discussion.  Personally, I like to see open discussions
over ones that are behind closed doors.  Plus, I suspect that hearing our
collective voices aids the ASP.NET MVC team in setting democratic priorities.

g.


Gerry Lowry, Principal
Ability Business Computer Services ~~ Because it's your Business, our Experience Counts!
68 John W. Taylor Avenue
Alliston · Ontario · Canada · L9R 0E1 · gerry.lowry@abilitybusinesscomputerservices.com
0
gerrylowry
3/25/2009 1:44:34 PM

 Is there a MVC roadmap? Just wonder when they plan on releasing the next incremental release or if they are just going to release MVC 2.0

0
j
3/25/2009 1:58:18 PM

Sorry, I'm just a low level community member ... don't know.  It may be possible
to get some hints from the "futures" published along with the "ASP.NET MVC v1.0 Source"
at  http://aspnet.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=24471.

If we are lucky, the ASP.NET MVC team will respond to your question.
I suggest that you start it as a new thread.

gerry


Gerry Lowry, Principal
Ability Business Computer Services ~~ Because it's your Business, our Experience Counts!
68 John W. Taylor Avenue
Alliston · Ontario · Canada · L9R 0E1 · gerry.lowry@abilitybusinesscomputerservices.com
0
gerrylowry
3/25/2009 2:24:59 PM

minor editorial point (following Figure 13):

Editing Existing Database Records

In the previous sections, we discussed how you can list and create new database records.
In this final section, we discuss how you can edit existing database records.


I can not imagine ever editing non-existing database records.      gerry

 


Gerry Lowry, Principal
Ability Business Computer Services ~~ Because it's your Business, our Experience Counts!
68 John W. Taylor Avenue
Alliston · Ontario · Canada · L9R 0E1 · gerry.lowry@abilitybusinesscomputerservices.com
0
gerrylowry
3/25/2009 2:53:02 PM

1. Right-click    the      Edit() method in the code editor and select the menu option Add View (see Figure 14).
1. Right-click either Edit() method in the code editor and select the menu option Add View (see Figure 14).

  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

First, we need to modify the Index view.
The Index view renders an Edit link next to each movie record.
We need to modify this link so that it passed the correct primary key to the Edit view.

Find the following line of code in the Index view:

/* id=item.PrimaryKey */ }) %> |

Replace the comment /* id=item.PrimaryKey */ with the actual primary key property so that the modified line of code looks like this:

{id=item.Id}) %> |

[A] This has already be done in the RTM.

[B] It has been done for "Details" too.

<td>

<%= Html.ActionLink("Edit", "Edit", new { id=item.Id }) %> |

<%= Html.ActionLink("Details", "Details", new { id=item.Id })%>

</td>

gerry (lowry)


Gerry Lowry, Principal
Ability Business Computer Services ~~ Because it's your Business, our Experience Counts!
68 John W. Taylor Avenue
Alliston · Ontario · Canada · L9R 0E1 · gerry.lowry@abilitybusinesscomputerservices.com
0
gerrylowry
3/25/2009 6:37:21 PM

Suggestionhighlight changes within the tutorial to make them easier to follow.

Example:  in Listing 6 – Controllers\HomeController.cs (Edit methods):

public ActionResult Edit(int id)
{
    var movieToEdit = (from m in _db.MovieSet
                       where m.Id == id
                       select m).First();

   
    return View(movieToEdit);
}


[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Edit(Movie movieToEdit)
{
    if (!ModelState.IsValid)
        return View();
   
    try
    {
        var originalMovie = (from m in _db.MovieSet
                           where m.Id == movieToEdit.Id
                           select m).First();

        _db.ApplyPropertyChanges(originalMovie.EntityKey.EntitySetName, movieToEdit);
        _db.SaveChanges();

        return RedirectToAction("Index");
    }
    catch
    {
        return View();
    }
}

For me, when it's easy to see the changes, I'm less likely to
miss something which then causes me to think that the tutorial
is broken.


Gerry Lowry, Principal
Ability Business Computer Services ~~ Because it's your Business, our Experience Counts!
68 John W. Taylor Avenue
Alliston · Ontario · Canada · L9R 0E1 · gerry.lowry@abilitybusinesscomputerservices.com
0
gerrylowry
3/26/2009 2:07:33 AM

>>Is there a MVC roadmap?
ASP.NET MVC Road Map

>>Do MS read these forums and add the requests to new releases?
Yes we do. The forum feedback provides valuable input to the product direction.

>>Features like the optional prevention of duplicate records could be controlled via [attribute] usage. 

Dup ID's validation ultimately is the responsibility of the DB. That would be very difficult to achieve in an attribute. While you can proactively check for dups, between the time you check and submit, another user could enter data making your submission a dup. See see this post. for how dup checking is done in Dynamic Data.


Rick -ASP.Net UE  My DD Blog  DD FAQ
0
ricka6
3/26/2009 5:38:22 PM

Hi Gerry,

Thanks for your valuable feedback. 

>>Suggestionhighlight changes within the tutorial to make them easier to follow.

The tutorials are aimed as introductions to MVC, not as "what's changed since the last version". Not only would highlighting changes be confusing to new folks, the significant effort to highlight changes would limit content additions. I'd much rather see Stephen write new content than focus on change book keeping.

>>[A] This has already be done in the RTM.

Thanks for bringing this to our attention. I missed it in my review. Those sort of changes are very difficult for the original author to discover, I'll take the blame for that one.


Rick -ASP.Net UE  My DD Blog  DD FAQ
0
ricka6
3/26/2009 6:00:52 PM

Hi Rick, sorry, but I guess it's my fault for not being clear enough.

By  "Suggestionhighlight changes within the tutorial to make them easier to follow."
I was not referring to whether the changes had to do with the progress from CTP to RTM.

I meant, for the person who is following any given tutorial from start to finish,
show the changes to make it easier for the person to follow.

What made me think of this was that I missed the changes to the parameter
of the second Edit method.  I then wasted my time debugging my failure
to effectively copy and paste.  Quoting Forest Gump with regards to myself,
"stupid is as stupid does".  Highlighting would have helped me be less stupid.

Also, even for people who only read without hands on trying the tutorials, highlighting
makes the top to bottom read easier when it is clear what code has changed.
The longer in inches or feet the tutorial is from top to bottom,
the more necessary it is to use appropriate highlighting.

Authors like Tom Archer of "Inside C#" use this technique.

In fact, highlighting is extremely valuable even when code is presented
only once in a tutorial.  Example, compare:

    public delegate void EnumConnectionsCallback(DBConnection connection);
      public static void EnumConnections(EnumConnectionsCallback callback)

with

    public delegate void EnumConnectionsCallback(DBConnection connection);
      public static void EnumConnections(EnumConnectionsCallback callback)

Gerry


Gerry Lowry, Principal
Ability Business Computer Services ~~ Because it's your Business, our Experience Counts!
68 John W. Taylor Avenue
Alliston · Ontario · Canada · L9R 0E1 · gerry.lowry@abilitybusinesscomputerservices.com
0
gerrylowry
3/26/2009 6:40:00 PM

Got it. Yes, incremental changes are difficult to spot.


Rick -ASP.Net UE  My DD Blog  DD FAQ
0
ricka6
3/26/2009 6:46:47 PM
Reply:

Similar Artilces:

Are there any C# video tutorials for .Net MVC?
...does anyone know if any .net mvc C# video tutorials exist somewhere?  I don't know VB at all and I'm tired of trying to convert it over on the fly while watching the tutorials. For the folks here creating the videos, is it too much to ask that some C# videos be made?  Sure VB is popular and all but there is this language called C# that the rest of your developers use.   http://www.asp.net/learn/mvc/ you can convert VB.NET code to C# using the link below..http://www.developerfusion.com/tools/convert/vb-to-csharp/Jerry JosephIT Consultant~ Please Mark as Answe...

Developed C#.net WebService 1.1 for Client C#.net 1.1. Getting error "Server was unable to process the Request" Pls Help
Hi., I developed Microsoft C#.net Web Services2003 for the Client Application C#.net 2003. When it runs in 5 machines it gives good performance and has no errors. But if i run the same application in about 80 client machines. Getting error "Server was unable to process the request". I use Sql Server 2005 as my database. I get error even when i login at a time for about 25 users. Tried modifying machine.config too. But went unsuccessful. Live Server is 2003 using IIS 6.0 I use very expensive data handling.  Its very urgent pls help. Have to post in Live Server. Thank u., ...

Sending SMS using vb.net or C#.net using vb.net or c#.net
Hi  My requirement is I hav one csv file with these fields id,mobilenum,messgae,status.intiallu staus is 0. once i read the all fileds and take that mobile number.using tat mobile number  i need to send sms .after sending sms i shuld change status as 1 How to send sms thru coding (please dont provide any links.if it is provide also please give working links becox i checked codeproject .i didnt get any nice link. and also provide the how to update the status field im csv file   Thank ssandhya   To send SMS, you need some third party SMS providers. if you consul...

use VB.NET and C#.NET code in the same C#.NET project
All-- Here is a sample that is "off the beaten path", (at least for me). Is it possible, in an ASP.NET application, using the code-behind page building technique, to have both pages written in VB.NET and pages written C#.NET?At http://www.WebLogicArts.com/DemoList.aspx there is a sample that shows that, (contrary to popular belief), it IS possible to mix ASP.NET pages built with C#.NET with ASP.NET pages built with VB.NET in the same VS.NET 2003 project. Note that this is just a "fun" sample to see if it can be done and I do not recommend this practice as a "standard" way of develo...

.Net 2.0 Web application using Vb.net is unable to create object of another dll writen in C# .net 2.0
Hi, I habe created one ASP.net web application using Vb.net which is adding reference of dlls written in C# and .net 2.0. But whenever trying to create object of referencing dll, it is throwing error :Object reference does not set to an object. But, locally it is working fine,. In the server i have deployed the .aspx files and dll files in the bin. There were already an web.config in the server which is of .net 1.1. But checked it is retrieving value for that web.config correctly. Should i have to deply any other files and if not what can be the solution for this? Please help. Thanks, So...

New to MVC & MVC.net
Hi, I have never used the MVC design pattern before and the same applies for the new mvc.net. I have been working with ntier all the time. Where should i start to learn mvc and hence mvc.net so that i can use it in my software projects and have more grasp on it. Thanks. Sultan   Hi, start by taking a look at the videos here: http://www.asp.net/learn/3.5-SP1/. The ones about MVC and MVC storefront. Grz, Kris.Read my blog. Handy Firefox plugins for web developers.Workaround for non working Mark as answer buttons. I'd start with ScottGu's blog: http://weblogs.asp.net/sco...

converting to vb.net from c#.net authorize.net
authorize.net offered me some sample code when I signed up with them the only problem is the sample code is in c#.net but my page that they type all of their credit card into is vb.net <code><%@ Import Namespace="System.Net" %> <%@ Import Namespace="System.IO" %> <script language="C#" runat="server"> void Page_Load(Object Src, EventArgs E) { myPage.Text = readHtmlPage("https://certification.authorize.net/gateway/transact.dll"); } private String readHtmlPage(string url) { ...

Problems while porting .Net framework 1.0 (VB.Net) application to .Net Framework 1.1
Hello,   I have a ASP.Net web application,written in VB.Net,developed on .Net Framework 1.0 .I am trying to port it on to .Net framework 1.1.   For achieving this,I follow the following steps-   1.Open the project using the .vbproj file. 2.I am prompted with the conversion message "Do you want to convert the solution and all projects to .Net framework  1.1....." 3.I click "Yes" 4.I assume that the project is now converted. 5.I build the project & try to run it. 6.I get the following error -     Server Error in '/Consert.Net' Application. ...

Differences between .net 1, .net 1.1, .net 2.0 and .net 3.0
Hi, This seems to be a common question, but i havent got an answer yet:(Can, any one please explain me the differences between these versions.If you keep your feet firmly on the ground, you'll have trouble putting on your pants! Have a look into this links http://en.wikipedia.org/wiki/.NET_Framework http://blogs.msdn.com/mohammadakif/archive/2006/12/03/net-3-0-different-versions-of-the-net-framework.aspx http://www.codeproject.com/aspnet/ComparisonASP1xASP20.aspAshok Rajawww.iGold.inDon't forget to click "Mark as Answer" on the post that helped you. This credits that m...

Porting VB.Net application to .Net Framework 1.1
Hello,   I have a ASP.Net web application,written in VB.Net,developed on .Net Framework 1.0 ,which,I am trying to port on to .Net framework 1.1.   For achieving this,I follow the following steps-   1.Open the project using the .vbproj file. 2.I am prompted with the conversion message "Do you want to convert the solution and all projects to .Net framework  1.1....." 3.I click "Yes" 4.I assume that the project is now converted. 5.I build the project & try to run it. 6.I get the following error -     Server Error in '/Consert.Net' Appli...

Differences between .net 1, .net 1.1, .net 2.0 and .net 3.0 #2
Hi, This seems to be a common question, but i havent got an answer yet:(Can, any one please explain me the differences between these versions.If you keep your feet firmly on the ground, you'll have trouble putting on your pants! There are too many differences for one email - - from 1.0 to 1.1 (not a whole lot of real change, other than fixes, at least compared to 1.1 to 2.0) With 2.0, there were many new declarative controls, with many new ideas added in With 3.0, it's a superset of 2.0 - instead of replacing the installation completely, it just 'added on' new functionality - I would...

Integrating the C#.net and VB.net application
Hello All,  I'm trying to integrate the C#.net application and VB.net application.  Can you give me any suggestions of how to merge them.  Thanks in Advance You are probably goign to have to convert one of the applications to the other language at one point.  There are online conversion tools to help http://www.carlosag.net/Tools/CodeTranslator/- WilliamPlease mark the most helpful reply/replies as "Answer".Give some of my PWSK modules a try.  Type of application?We All move to our original place.Don't forget.Imran Baloch @weighfield: I d...

Convert VB.Net application to C#.net
Haican any one help me to convert VB.Net application in this link to C#.net http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=6718&lngWId=10RegardsAnu Palavila  Regards Anu Palavila Use this Free Conversion tool - http://www.developerfusion.com/tools/convert/vb-to-csharp/  ASP.NET Grid With Excel Capabilities | 27 GridView Tips & Tricks | Hosting your site? | SQL Server Tips Other Code Convertors (convert VB to C# and C# to VB) http://converter.telerik.com/ http://www.developerfusion.com/tools/convert/csharp-to-vb/ http://www.dotnetspider.com...

vb.net vs c#.net vs j#.net
just out of curiousity which looks, acts most like java? i'm still learning trying to used to vb.net but it seems that it was easier to do some stuff with java. C# is Java++ in my opinion. If you have done C or Jave you will prefer C#.Mike Schellenberger - MCAD If you are looking for language similar to java go for J#. However most code samples you find on the net will be in VB.NET and C#....

C#.NET in VS.NET vs. C# in Web Matrix
Hi all, I am very new to .NET ... I realized C#.NET is only available from Visual Studio.NET ... however, I realized Web Matrix also allowed us to choose C# as language but not C#.NET ... they are not the same, right? If not, then why it's in Web Matrix which runs ASP.NET?? If I need to run C#.Net, I MUST GET VS.NET, right? Can C#.NET has the abality to create chat program? Thank you very much. C#.NET and C# are the same thing. JimMS MVP ASP.NET [VC++/MFC emeritus]Old Dog Learns New TricksPreferred programming language: cuneiform on clay tablets So ... that means I can use web matrix t...

Web resources about - Tutorial 1: c#, f.y.i.: errors in the first ASP.NET MVC tutorial ... Creating a Movie Database Application with ASP.NET MVC (C#) - asp.net.mvc

Application - Wikipedia, the free encyclopedia
Text is available under the Creative Commons Attribution-ShareAlike License ;additional terms may apply. By using this site, you agree to the ...

Welfare experiment may have applications in Australia
A trial in Finland providing an obligation-free basic income could change how we think about welfare.

AVO application against Labor's Jamie Clements withdrawn
An application for an apprehended violence order against Labor powerbroker Jamie Clements - based on allegations he tried to kiss a female staffer ...

Patent application shows Apple Watch band that transforms into a case, stand and Mac accessory
An Apple patent application published today reveals an idea for an interesting variation on the magnetically-closed Milanese Loop band that allows ...

Seagate Introduces First 8 TB Hard Disk Drive for Consumer NAS Applications
Seagate Technology on Tuesday introduced its new breed of hard disk drives (HDDs) for network area storage (NAS) and RAID applications. The new ...

MBA: Mortgage Applications Increased in Latest Weekly Survey, Purchase Applications up 19% YoY
From the MBA: Mortgage Applications Increase in Latest MBA Weekly Survey Mortgage applications increased 21.3 percent from one week earlier, ...

Mortgage applications sink after rush
A Fed rate hike pulled mortgage demand forward, and made for a steep drop-off in the past two weeks.

SURPRISE! Mizzou Sees Application Drop After Days Of Protests, Illusory Klan Hoods, Poop Swastika
SURPRISE! Mizzou Sees Application Drop After Days Of Protests, Illusory Klan Hoods, Poop Swastika

In Application To Move To Los Angeles, Rams Shit All Over City Of St. Louis
... to relocate to the greater Los Angeles metropolitan area. The relocation would be effective for the 2016 NFL League Year.” The Rams’ full application ...

Seagate pushing non-PC storage for 2016 with focus on surveillance applications
... products for cloud computing, consumer electronics, surveillance and enterprise storage for 2016. Seagate expects surveillance-related applications ...

Resources last updated: 1/17/2016 9:26:12 AM