Reputation: 91
I've got an MVC project, and I want to add Identity to it, but I can't seem to find any good articles on how to do so.
Is there an easy way to add Identity to an existing project?
I already have a database with stuff in it
Upvotes: 8
Views: 12674
Reputation: 159
I'm getting back there because I ran into this situation some time back and applied solutions from here. In the meantime I found something simpler. VS has you covered to actually scaffold the files.
Right-click the project ► Add ► New Scaffolded Item...
Then in the new dialog, select Identity and click Add.
On the next screen you'll be given a list of items to check. You don't need to but you can import all of them if you want. It will ask for the data context but there's not in my case. In yours it should be already filled.
Click Add, you're done.
Upvotes: 1
Reputation: 195
I think the easiest way to do that is to do the following steps:
Install All Identity Packages from nugets to your existing MVC project.
Create New MVC Project and choose Authentication type: Individual Authentication.
Copy IdentityModels.cs and all related files including (controllers, views and IdentityConfig) from New project to an existing MVC project.
Add migration to create required tables on database.
Upvotes: 1
Reputation: 2539
I will echo what Chris said. there is no "easy way" . here is a video link featuring Scott Allen (a pioneer in web dev (Video link)
You can check his other videos as well
Upvotes: 1
Reputation: 484
Here's a tutorial that I followed for adding ASP.Net Identity to an existing project. It's up to date and from a reputed source at the asp.net/identity site.
Upvotes: 4
Reputation: 239460
Well, in one respect, you simply have to add the Nuget package and start writing code with it, but I think you're probably talking about all the extras: the pre-written code and samples for doing things like password resets, two-factor auth, etc.
For that, no, there's not really an easy way, at least in the sense of click a button and go. What I would recommend is creating a new MVC 5 project with Individual Auth, and then adding the Identity Samples Nuget package to it. Then, open your existing project in another Visual Studio window and copy/paste or use the sample code as a guide for writing your own.
Upvotes: 9