Note that there are some explanatory texts on larger screens.

plurals
  1. POASP.net MVC 3 is not creating a SQL table automatically (Following Pluralsight)
    primarykey
    data
    text
    <p>I am trying to follow this guide <a href="http://www.pluralsight-training.net/microsoft/players/PSODPlayer.aspx?author=scott-allen&amp;name=mvc3-building-data-i&amp;mode=live&amp;clip=0&amp;course=aspdotnet-mvc3-intro" rel="nofollow">http://www.pluralsight-training.net/microsoft/players/PSODPlayer.aspx?author=scott-allen&amp;name=mvc3-building-data-i&amp;mode=live&amp;clip=0&amp;course=aspdotnet-mvc3-intro</a> (Part 3 Code Comes first) but I have followed it like a slave.</p> <p>Now I have installed a MSDN version so its the Visual Studio Ultimate and not the Web developer express 2010 like he uses and I wonder is that the sole reason for this not working? Because then I will just install that instead.</p> <p>I get this error when I try to access a site that should use the database</p> <blockquote> <pre><code> Server Error in '/' Application. Value cannot be null. Parameter name: key Description: An unhandled exception occurred during the </code></pre> <p>execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.</p> <pre><code>Exception Details: System.ArgumentNullException: Value </code></pre> <p>cannot be null. Parameter name: key</p> <pre><code>Source Error: Line 15: Line 16: Line 17: @foreach (var item in Model) Line 18: { Line 19: @item.Title Source File: c:\Users\Mech0z\Documents\Visual </code></pre> <p>Studio 2010\Projects\FirstWeb\FirstWeb\Views\Gallery\Index.cshtml Line: 17</p> <pre><code>Stack Trace: </code></pre> </blockquote> <p>My code is:</p> <p>Connectionstring:</p> <pre><code>&lt;connectionStrings&gt; &lt;add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient" /&gt; &lt;add name="GalleryDb" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;initial catalog=GalleryDb" providerName="System.Data.SqlClient"/&gt; &lt;/connectionStrings&gt; </code></pre> <p>Picture model </p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace FirstWeb.Models { public class Picture { public int ID { get; set; } public string Title { get; set; } public string Path { get; set; } public List&lt;Comment&gt; Comments { get; set;} public int ConcertYear { get; set; } public HttpPostedFileBase File { get; set; } public string UploadBy { get; set; } } } </code></pre> <p>My controller </p> <pre><code>namespace FirstWeb.Controllers { public class GalleryController : Controller { GalleryDb _db = new GalleryDb(); // // GET: /Gallery/ public ActionResult Index() { var model = _db.Pictures; return View(model); } </code></pre> <p>And my galleryDB</p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Data.Entity; namespace FirstWeb.Models { public class GalleryDb : DbContext { public DbSet&lt;Picture&gt; Pictures { get; set; } public DbSet&lt;Comment&gt; Comments { get; set; } public DbSet&lt;Picture&gt; GetPictures() { return Pictures; } public void AddPicture(Picture model) { Pictures.Add(new Picture { Title = model.Title, Path = model.Path, Comments = new List&lt;Comment&gt;(), ConcertYear = model.ConcertYear }); } } } </code></pre> <p>I have a few extra methods thats not workign whicih is just something from when I used temp data without SQL</p> <p>But as said I cant connect to the db the way he does (Typing .\sqlexpress and typing GalleryDb as name) and it gives me an error</p> <p>But the database must be running as I can create a user and login at any point</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload