locked
ASP.NET MVC 5 Identity Sample - Program hangs during database initialization RRS feed

  • Question

  • Hello,

    I installed this sample

    https://www.nuget.org/packages/Microsoft.AspNet.Identity.Samples

    It used to work perfectly, then it stopped working.

    I tried the following

    • Change data source type
    • Recreate database file
    • Create new project and install a clean copy of the sample (It works for sometime until it does not)

    This is the code of interest

    //Create User=Admin@Admin.com with password=Admin@123456 in the Admin role        
            public static void InitializeIdentityForEF(ApplicationDbContext db) {
                var userManager = HttpContext.Current.GetOwinContext().GetUserManager<ApplicationUserManager>();
                var roleManager = HttpContext.Current.GetOwinContext().Get<ApplicationRoleManager>();
                const string name = "admin@example.com";
                const string password = "Admin@123456";
                const string roleName = "Admin";
    
                //Create Role Admin if it does not exist
                var role = roleManager.FindByName(roleName);     // <----------- The program hangs here
                if (role == null) {
                    role = new IdentityRole(roleName);
                    var roleresult = roleManager.Create(role);
                }
                /// ....
            }
        }

    Other code portions you might find interesting

    public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
        {
            public ApplicationDbContext()
                : base("FormConnection", throwIfV1Schema: false)
            {
            }
    
            //// ...
        }

    Connection strings (With previously tried strings)

    <connectionStrings>
        <!--<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=SomeProject-2-1-alpha1;Integrated Security=SSPI" providerName="System.Data.SqlClient" />-->
      <!--<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFileName=|DataDirectory|\Form.mdf;Initial Catalog=Form;Integrated Security=true" providerName="System.Data.SqlClient" />-->
      <!--<add name="FormConnection"
        providerName="System.Data.SqlClient"
        connectionString="Data Source=(LocalDB)\v11.0;AttachDbFileName=|DataDirectory|\Form.mdf;Initial Catalog=DatabaseName;Integrated Security=True;MultipleActiveResultSets=True" />-->
      <add name="FormConnection"
        providerName="System.Data.SqlClient"
        connectionString="Data Source=.\SQLEXPRESS;AttachDbFileName=|DataDirectory|\Form.mdf;Integrated Security=True;User Instance=True;MultipleActiveResultSets=True" />
    </connectionStrings>

    I can access the database tables using server explorer as well as insert data to the database.

    Thank you in advance :)


    • Edited by indielabs Wednesday, October 29, 2014 1:51 PM
    • Moved by Eyal Solnik Thursday, October 30, 2014 1:38 PM Irrelevant to C#
    Wednesday, October 29, 2014 1:48 PM

Answers

All replies

  • check any lock is there on table or not, 

    using sp_who , or sp_lock

    please look at the below link

    https://sites.google.com/site/mssqlserverworkstation/follow-me/blog/howtofindlockedtablesandkillsessioninsqlserver

    Wednesday, October 29, 2014 1:54 PM
  • Please post questions related to ASP.NET in the ASP.NET forums (http://forums.asp.net ).
    • Proposed as answer by Just Karl Thursday, October 30, 2014 10:36 PM
    • Marked as answer by Just Karl Thursday, November 20, 2014 10:29 PM
    Wednesday, October 29, 2014 2:04 PM
  • check any lock is there on table or not, 

    using sp_who , or sp_lock

    please look at the below link

    https://sites.google.com/site/mssqlserverworkstation/follow-me/blog/howtofindlockedtablesandkillsessioninsqlserver

    Thank you for your reply :)

    This query

    select cmd,* from sys.sysprocesses
    where blocked > 0

    produced 0 results, for this reason, I think there are no locks.

    Here are the results of sp_lock and sp_who if you are interested

    sp_lock

    spid dbid ObjId IndId Type Resource Mode Status
    51 1 1467152272 0 TAB IS GRANT

    sp_who

    spid	ecid	status	loginame	hostname	blk	dbname	cmd	request_id
    1	0	background                    	sa	                                                                                                                                	0    	NULL	LOG WRITER      	0
    2	0	background                    	sa	                                                                                                                                	0    	NULL	RECOVERY WRITER 	0
    3	0	background                    	sa	                                                                                                                                	0    	NULL	LAZY WRITER     	0
    4	0	background                    	sa	                                                                                                                                	0    	NULL	LOCK MONITOR    	0
    5	0	background                    	sa	                                                                                                                                	0    	master	SIGNAL HANDLER  	0
    6	0	background                    	sa	                                                                                                                                	0    	NULL	RESOURCE MONITOR	0
    7	0	background                    	sa	                                                                                                                                	0    	NULL	XE DISPATCHER   	0
    8	0	background                    	sa	                                                                                                                                	0    	NULL	XE TIMER        	0
    9	0	background                    	sa	                                                                                                                                	0    	master	BRKR TASK       	0
    10	0	sleeping                      	sa	                                                                                                                                	0    	master	TASK MANAGER    	0
    11	0	background                    	sa	                                                                                                                                	0    	master	TRACE QUEUE TASK	0
    12	0	background                    	sa	                                                                                                                                	0    	NULL	RECEIVE         	0
    13	0	background                    	sa	                                                                                                                                	0    	master	TASK MANAGER    	0
    14	0	background                    	sa	                                                                                                                                	0    	master	CHECKPOINT      	0
    15	0	background                    	sa	                                                                                                                                	0    	master	BRKR EVENT HNDLR	0
    16	0	background                    	sa	                                                                                                                                	0    	master	BRKR TASK       	0
    17	0	background                    	sa	                                                                                                                                	0    	master	BRKR TASK       	0
    18	0	background                    	sa	                                                                                                                                	0    	master	BRKR TASK       	0
    19	0	sleeping                      	sa	                                                                                                                                	0    	master	TASK MANAGER    	0
    20	0	sleeping                      	sa	                                                                                                                                	0    	master	TASK MANAGER    	0
    21	0	sleeping                      	sa	                                                                                                                                	0    	master	TASK MANAGER    	0
    22	0	sleeping                      	sa	                                                                                                                                	0    	master	TASK MANAGER    	0
    23	0	sleeping                      	sa	                                                                                                                                	0    	master	TASK MANAGER    	0
    24	0	sleeping                      	sa	                                                                                                                                	0    	master	TASK MANAGER    	0
    25	0	sleeping                      	sa	                                                                                                                                	0    	master	TASK MANAGER    	0
    26	0	sleeping                      	sa	                                                                                                                                	0    	master	TASK MANAGER    	0
    27	0	sleeping                      	sa	                                                                                                                                	0    	master	TASK MANAGER    	0
    28	0	sleeping                      	sa	                                                                                                                                	0    	master	TASK MANAGER    	0
    29	0	sleeping                      	sa	                                                                                                                                	0    	master	TASK MANAGER    	0
    30	0	sleeping                      	sa	                                                                                                                                	0    	master	TASK MANAGER    	0
    31	0	sleeping                      	sa	                                                                                                                                	0    	master	TASK MANAGER    	0
    32	0	sleeping                      	sa	                                                                                                                                	0    	master	TASK MANAGER    	0
    33	0	sleeping                      	sa	                                                                                                                                	0    	master	TASK MANAGER    	0
    51	0	runnable                      	Amri-PC\Amri	AMRI-PC                                                                                                                         	0    	master	SELECT          	0


    • Edited by indielabs Thursday, October 30, 2014 7:40 AM
    Thursday, October 30, 2014 7:37 AM
  • Please post questions related to ASP.NET in the ASP.NET forums ().

    Thank you,

    You can find the post in asp.net forums with the same title

    http://forums.asp.net/p/2015380/5800810.aspx?p=True&t=635502375394508450&pagenum=1

    • Edited by indielabs Thursday, October 30, 2014 7:48 AM
    Thursday, October 30, 2014 7:48 AM