ASP.NET Identity Create an Account -


I am using ASP.NET MVC 5.0 EF 6.0 and Identity 1.0.

I is a seed festival which currently runs successfully and incorporates various pieces of data such as 'teacher' into the database. I would like to expand the seed festival, so that when I make a new teacher, it also creates a new user account in the aspen's table.

I have tried the following code in the 'SampleData.cs' file:

  Using the system. Colllections.Generic; Using System.Linq; Using System.Data.Entity; Using Oberhofen.EdNow.Data.Models; Using Oberhofen.EdNow.Model.Models; Using Microsoft.AspNet.Identity; Using Microsoft.AspNet.Identity.EntityFramework; Using the system; Nameshot Oberhofen.Adnov.Data {Public class Adenospledata: DropCreate DibSimedel Changes & lt; Adenovantitis & gt; {Personal User Manager & lt; ApplicationUser & gt; UserManager; Protected Override Zero Seed (EdenNews Reference) {// Create a new account String Username = "Volock"; String password = "password"; Var user = new applicationUser {user name = username, email = "zzzz@gmail.com"}; Var result = userManager.Create (user, password); Var userId = user.Id; // Create new teachers Var teacher = new list & gt; Teacher & gt; {New teachers {first name = "walter", last name = "lockhart", personalit id = 2, user id = user id}}; Teachers ForEach (tchr = & gt; Reference Tester. Add (TCR)); Context.Commit (); }}}   

When I run the code on the line:

  var result = userManager.Create (user, password);   

I get the following exception:

Microsoft.AspNet.Identity.Core.dll & gt; Exception to a type 'System.ArgumentNullException' typed in. But the code that was not handled in the user code could not be zero. Parameter Name: Manager

Can someone please advise me what is missing in my code which can be an exception.

Thanks in advance.

Walter

Before you remove the result, Should:

/ P> User Manager = New User Manager & lt; ApplicationUser & gt; ();

or set to null in the declaration.

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -