Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to test if my linq query went through
    text
    copied!<p>This is my code from my controller:</p> <pre><code>MGEntities db = new MGEntities(); [HttpPost] public ActionResult Register(RegisterModel model) { if (ModelState.IsValid) { // Attempt to register the user MembershipCreateStatus createStatus = MembershipService.CreateUser(model.UserName, model.Password, model.Email); if (createStatus == MembershipCreateStatus.Success) { FormsService.SignIn(model.UserName, false /* createPersistentCookie */); MembershipUser myObject = Membership.GetUser(); Guid UserID = (Guid)myObject.ProviderUserKey; MyProfile profile = new MyProfile(); profile.Address = model.Address; profile.City = model.City; profile.Zip = model.Zip; profile.State = model.State; profile.UserId = UserID; Debug.Write(profile.State); db.aspnet_Profiles.Add(profile); return RedirectToAction("Index", "Home"); } else { ModelState.AddModelError("", AccountValidation.ErrorCodeToString(createStatus)); } } </code></pre> <p>This is my MyProfile Class:</p> <pre><code>namespace MatchGaming.Models { [Bind(Exclude = "ProfileId")] public class MyProfile { [Key] [ScaffoldColumn(false)] public int ProfileId { get; set; } public Guid UserId { get; set; } [DisplayName("Address")] public string Address { get; set; } [DisplayName("City")] public string City { get; set; } [DisplayName("Zip")] public string Zip { get; set; } [DisplayName("State")] public string State { get; set; } } } </code></pre> <p>After the linq query is executed, i check my database and nothing is added. I am using POCO for my entities. Here is my class:</p> <pre><code>namespace MatchGaming.Models { public class MGEntities : DbContext { public DbSet&lt;MyProfile&gt; aspnet_Profiles { get; set; } } } </code></pre> <p>I basically just dont understand why its not adding to the database, if theres a way I can check if the query went through correctly or not or if anyone can see the problem. Thank you!</p>
 

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