How to create new project with own database and authentication - asp.net-mvc

I am trying to create a new web MVC project in Visual Studio 2015. I want to use my own database which already exists, and I want to add authentication models and controllers when creating the project.
The issue is:
When I create a new MVC project I can choose the type of authentication but I can't choose what database it uses. So the project is being created with its own local database while I want to use mine so that all necessary tables and DB objects are created in my own database.
I can't even find the LocalDB file created with the project to export the authentication data to my own database.
When I try to connect to the DB it asks me to browse for the mdf file and I have no clue where the file has been created. I did a search in Explorer for the mdf file but found nothing.

I got how to make it working! In case someone has the same problem these are the steps:
Visual Studio creates the defaultConnection - Yes.
But it doesn't create the tables (or probably even the database itself).
So I did the following:
Installed the project (ASP.NET Core Web Application with Framework template) using Individual User Accounts option as authentication.
Then went to appsettings.json and changed the connection string for my own database. (There is no needs to create asp auth tables, only have your own database ready)
I clicked debug and got the website displayed.
Clicked register and registered new user - I got the screen with button to do the migration.
I clicked the button and refreshed the page.
Went to my database and saw all tables have been created in there and the user inserted in the database.
I hope this helps anyone.

Related

ASP.net MVC: Creating a Simple Log-in Form in Visual Studio

I'm creating a simple ASP.net MVC login form using individual user accounts. I created the project following this tutorial: https://learn.microsoft.com/en-us/aspnet/mvc/overview/security/create-an-aspnet-mvc-5-app-with-facebook-and-google-oauth2-and-openid-sign-on
At what point do I connect it to my SQL Server database? In the tutorial, it seems as though the database tables are created automatically, though I've never seen an option to enter my database credentials.
Thanks!
The default template generates you a local database that is stored in the project directory. If I recall correctly, it does not require authentication. You can examine the Web.config file to see the connection string. It will not contain a username and password because it does not require them for that local database.

Creating Database Project from Database in Azure

Here are the steps I took:
In Visual Studio, I created an ASP.NET MVC application with authentication
I specified that the database is an Azure SQL Database living in the cloud
So at this point I have a single project in my solution, the web application project for ASP.NET. And I have this database created in Azure with my membership database objects.
Now what I want to do is create a database project in this same solution for more detailed and in depth database development.
I created a database project, and I can easily set to deploy to Azure but I would be "overwriting" the Azure database that was created initially.
How can I "refresh" the database project I just created to reflect the existing database in Azure at this point so I'm not overwriting?
Basically I'm looking to "sync" up the existing Azure SQL Database with the new database project I just created in the solution.
Any way to do this?
Thanks in advance!
Basically what you want is the Schema Compare feature from SSDT (Sql Server data tools)
https://msdn.microsoft.com/en-us/library/hh272690(v=vs.103).aspx

entity framework db first

I have built my MVC 5 project based on entity framework Database First approach by following video tutorials. But what I have obtained is the model. There is nothing in the app_data folder. I want to obtain the .mdf file as well so that I can deploy the database to the azure.
Note: I'm using the server explorer database in VS2013.
I dont think you will be getting any .mdf files on app_data folder.
To deploy your database to Azure:
Right click your database on SQL server, then Tasks->Generate Scripts. On scripting options, select sql azure server
Login to your azure account and create a SQL server and run generated script from the portal by clicking the link below:
while creating your EF connection, use the connection string for your Azure Database like:
At the end you should be ready to use your ORM.

Default login asp.net MVC3

Where is the login information (username, password) actually stored by using the default template from ASP.NET MVC application in VS2010? I mean, is it physically registered in a database, file or something else?
Upon registering the first user a database named ASPNETDB.MDF under the application’s
App_Data directory is created. This information was supplied by default in the root web.config file.
There is no default login. There is not even a database created when you start a new project. You need to register a new user by clicking on the Register link on the login page. When you register a new user you will be prompted to specify the username and password and a database file will be created in the App_Data folder. Now you can go ahead and login with the account you have just created. And by the way the same stands true for ASP.NET MVC 1.0 and 2.0 project templates.
If you can't see the database under App_data, try clicking "Show all Files" which is one of the icons at the top of the solutions explorer. Then the database will show under App_data as something like ASPNETD8.MDF.

How to edit the user details stored in aspnetdb without asp.net web administration tool?

I have asp.net MVC application which uses asp.net membership. I configured the user details from local system using Asp.Net web site administration tool. Now I have deployed the site in server and I need to change the password. Now I have the ASPNETDB.MDF file in the App_Data folder.
How to edit the details?
Adding ASP.Net MVC Membership Starter Kit to your project is a great place to start, if you see ongoing edits being required.
You could do one of a couple of things. You can copy the MDF from the site to the local machine, and then change the details there, then copy the MDF back over, or you can implement a web page that changes the password using the SqlMembershipProvider.ChangePassword method.
You must call the method MembershipProvider.ChangePassword. See http://msdn.microsoft.com/en-us/library/system.web.security.membershipprovider.changepassword.aspx.

Resources