Note that there are some explanatory texts on larger screens.

plurals
  1. POSuccessfully extend custom SQL Datatables with aspnet_Membership tables
    primarykey
    data
    text
    <p>I have an application which I created using MVC3 and Custom SQL Database with 3 tables: <code>mm_Table1</code>, <code>mm_Table2</code>, <code>mm_Jobs</code></p> <p>I built out the MVC app with a <code>JobsController</code> and have the respective <code>Views</code> folder with <code>Create.cshtml</code>, <code>Delete.cshtml</code>, <code>Details.cshtml</code>, <code>Edit.cshtml</code> and <code>Index.cshtml</code></p> <p>I want to associate <code>mm_Profile</code> with a User.</p> <p>After integrating the <code>ASPNET_MEMBERSHIP</code> Tables into my custom database, I added a <code>UserId</code> column of Type <code>uniqueidentifier</code> to <code>mm_Jobs</code> and created the proper foreign key relationship to <code>aspnet_Users</code> table (<code>FK_Jobs_aspnet_Users</code>)</p> <p>I did so and now when I fill out my Jobs form (located in <code>Jobs -&gt; Create.cshtml</code>) and press the submit button I get the following error :</p> <pre><code>Cannot insert the value NULL into column 'UserId', table 'MovinMyStuff.dbo.Moves'; column does not allow nulls. INSERT fails. The statement has been terminated </code></pre> <p>The line of code in my JobsController in my <code>Create()</code> method:</p> <blockquote> <p>Line: 52 db.SaveChanges();</p> </blockquote> <p>How do I update my <code>Create()</code> to save change and associate the User with the Job, thus pushing the <code>UserId</code> into the <code>UserId</code> column in the <code>Jobs</code> table? The full create method is given below:</p> <pre><code> [HttpPost] public ActionResult Create(Job job) { if (ModelState.IsValid) { db.Moves.Add(job); db.SaveChanges(); return RedirectToAction("Index"); } return View(job); } </code></pre>
    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