Last post Jun 17, 2015 11:29 PM by ngaisteve1
Jun 15, 2015 12:06 PM|ngaisteve1|LINK
Hi, I am using Visual Express 2013. I realize that when I run the default registration page, a database named 'DbConn' was automatically created. I am not sure which code does that. My guess is IdentityModels.vb after I read up a bit. My next question is
how this database named 'DbConn' was automatically created? I couldn't find any code which define all these tables (below)
The tables in this newly created 'DbConn' are:
I could successfully insert the registered user into AspNetUsers table.
Jun 15, 2015 12:15 PM|ngaisteve1|LINK
Initially I didn't know that. So in my registration page, I populate my role drop down list from the table I created in my database. Now that I know this AspNetRoles is a 'dynamic' table, how do I load my drop down list for this role?
Jun 17, 2015 01:20 AM|kittyboy|LINK
when I run the default registration page, a database named 'DbConn' was automatically created. I am not sure which code does that.
The database will be created as a SQL Server CE (.sfd) or SQL Express (.mdf) file in the App_Data folder in your project, when you run the application for the first time and register as a user.
how this database named 'DbConn' was automatically created?
The ApplicationDbContext class passes a connection string name to the base class in the constructor, namely "DefaultConnection." If you open the Web.config file, we find that under the <connectionStrings> element there is a single node, in which the "DefaultConnection"
string is added to the connection strings collection.
so you can change the "DefaultConnection" string like below:
Initial Catalog=DbConn;User ID=xxx;Password=xxx"
Now that I know this AspNetRoles is a 'dynamic' table, how do I load my drop down list for this role?
you can try the below code:
Public Sub RolesBindingDropDownList() Dim dbContext As New ApplicationDbContext() ddlRoles.DataSource = dbContext.Roles.ToList() ddlRoles.DataTextField = "Name" ddlRoles.DataValueField = "ID" ddlRoles.DataBind()End Sub
Jun 17, 2015 11:29 PM|ngaisteve1|LINK
Thanks Kittyboy for much help. I realize that since I am still not familiar much with all these identity and running out of time, I created those tables manually and write my own simple code to add user and the role. Maybe next project, I will use this more
'advance' asp.net security features.