Adding Identity to an existing project - asp.net-mvc

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

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.

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.

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

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.

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.

Related

Unable to add Razor view to project

I can't add razor view to MVC 5 project in Visual Studio 2017.
There just doesn't seem to be the template
As you can see if I choose Web from template list nothing is visible and all I see is Please choose a project type.
Now this is puzzling as I've seen this related SO post & this where both of them suggest to set project type GUID in .csproj.
I do have it set and it was there (I didn't add anything)
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
Looking at the list of GUIDs it seems that the first GUID suggests that this is ASP.NET MVC 5 project.
I also checked VS2017 installation and I do have web tooling installed
Any clue what I can also try to enable adding web templates to project?
Are you trying to add a new project to a solution or a new item to a project? Its not clear in your question?
Within your project (Solution Explorer), try right click on the Views Folder, choose add, New Item and see if you can find anything there?

How to change Authentication in Visual Studio 2013 during existing project

I want to change authentication of an existing project but I can't change it. Because, I couldn't find the "Change Authentication" button which exists during new project setup. Please tell me, how can I change authentication of existing project?
I think you cannot change that via a push off a button.
Perhaps compare two sample projects with the existing and desired authentication?!?

MVC5 not generating Model from Database after NuGet update

I am creating an MVC 5 Web Application with Visual Basic using Database First Approach. Recently I updated ALL NuGet packages and after that I'm unable to create Models from the Database.
As shown below, I can not select Tables and other DB objects from Database to include in my Model.
When I click finish, it generates an empty model as shown below:
One more weird thing I noticed is: As shown in this tutorial, it should show me a checkbox that says, Enable Extended Transact-SQL verification for common objects, but when I open the properties of my project, it doesn't show me this checkbox.
Now, my questions are:
If as I doubt, a NuGet package update has created this problem; which
package is it?
Is it possible to uninstall updates of NuGet packages
(as we do with Windows Updates)? If yes, How?
Any help would be appreciated. Please note that,
I've experience in Web Forms but I'm a beginner in MVC.
This issue
has started just after, I updated ALL packages when I was facing
this type of issue.
I created 3 projects with the same approach
before this update, and I succeeded every time generating the Models
from Database.
Please suggest!
Right click the .edmx file in the solution explorer and select 'open with..' Select the XML editor and open the file. Check if there are any errors in the file. Errors may show in the error list window or may show as comments in the file.

How do I add a source controlled (tfs) project to a solution and maintain binding?

I would like to create three separate ASP.NET MVC solutions, all pointing to the same Model project. How do I keep changes made from one solution update the others?
Ex, is there is way in Visual Studio to "Add new project from Source Control" like you can with a whole solution?
So you are hoping to have 3 solutions that share a common project.
You can achieve this in 2 ways.
NuGet
Have the project in it's own solution and create a NuGet package of the output, your other solutions can then consume the NuGet Package.
Shared Project
A shared project is easy to do, just ensure that your shared project is available in the same workspace as your solutions.Do a get latest, You can then just right click on the solution and choose add existing project.
Any changes you make will need to be checked back into source control, these changes will then appear in each 'copy' of the project in each of the different solutions.
The shared project works fine, but you may have to make some considerations when you come to building the solutions, the main one being that if you only make a change to the shared project would you want all of the solutions that consume it to be built on check-in?

Add existing project to solution "read only" in Visual Studio

Is it possible to add an existing project to a solution in "read-only" mode?
I got access to a big bunch of internal projects, from which I just need some functions for another solution. Since I'm new to the original solution I'd like to make sure I don't accidentally change any of the existing files and check them into the TFS.
The easiest way to do so, would be some sort of "Add existing project (read only)"-Function.
Is there any way to do so? Or are there any other ways to ensure I'm not accidentally changing any of the existing files?
I'm using MS Visual Studio 2013 Professional.
Copy the source controled version to a seperate folder, and then reference that one from you Solution. your not working with source controlled code then , so you can't break it!

Resources