I'm working on a new asp.net mvc 5 app for a small company and am trying to figure out how to create the membership database using the new asp.net Identity system. I thought there might be an admin interface I can use which would create the database and allow me to add a few users/roles. Is there an admin interface for this task or another way I will need to accomplish it? Are there any tutorials on doing something like this? All I have been able to find so far has dealt with external logins using other providers such as Facebook or Google.
I'm pretty sure that it's based off of Entity Framework Code First. When you create the db context, it should create the table for you automatically.
http://msdn.microsoft.com/en-us/data/jj193542.aspx
MVC 5 Template with VS2013 use ASP.NET Identity instead of membership provider and has no admin interface. After creating a new MVC5 project in VS2013, run the website. Once you register the first user on the web interface a local database will be created under the App_Data folder. You could rename the connection string to point to other database and register user again to create the database. To add users you could enable migration and use the seed method.
Scott Allen published a great video which might help you to understand ASP.NET Identity more
http://pluralsight.com/training/courses/TableOfContents?courseName=aspdotnet-mvc5-fundamentals&highlight=scott-allen_aspdotnet-mvc5-fundamentals-m2-katana*8#aspdotnet-mvc5-fundamentals-m2-katana
Related
First of all a similar question was asked on below link but since there is no satisfied and accepted answer I am asking again.
asp.net mvc modify default authentication system
When I create a default ASP.NET MVC application in Visual Studio 2015, there is a default authentication system. It has also a database with tables. What I want to do is using my own database for the default authentication system, so I can integrate it to an application easily. I can create same tables in my database for it.
I tried to find some references to tables like AspNetUsers in the code but I couldn't find anything.
I always created database first and create model from it automatically in ASP.NET MVC. So always there is reference for my tables in my code. But default ASP.NET MVC application seems different.
Which part of the code I should modify and how?
And also why couldn't I find any reference to tables in the code?
The tables are created by default when creating the project because of authentication.
If changed like this This table can not be created.
If you want to use authentication, you can use Asp.net Identity.
I have an application which is in .NET Framework version 4.5. It uses Web Forms and EntityFramework 6.1.1.
The EntityFramework's Context object is of type ObjectContext. I'm using ASP.NET Membership(the MembershipProvider is customized i.e Custom Membership) for managing the user account related operations.
I want to migrate my Web Forms application to ASP.NET Identity.
According to http://www.asp.net/identity/overview/migrations/migrating-an-existing-website-from-sql-membership-to-aspnet-identity article I think I have to do the following things to migrate to the ASP.NET Identity:
Convert the ObjectContext to DbContext(and correct the related codes)
Create the new tables needed for ASP.NET Identity and do the data migration.
Redefine the account section codes and other dependent codes as needed to match the business logic.(optional)
I have few questions in my mind:
1) I have customized the membership User table and there are several custom foreign keys associated with the User table. Will it still be feasible to migrate to the Identity system without losing any data?
2) As I'm using EntityFramework so DbContext is needed to migrate to Identity system. Can I use ObjectContext for ASP.NET Identity migration?
3) I'm NOT using all the Membership tables as listed at http://i1.asp.net/media/48109/image006.png?cdn_id=2014-11-11-001. (i.e aspnet_Applications, aspnet_Membership, aspnet_Paths, aspnet_PersonalizationAllUsers, aspnet_PersonlizationPerUser, aspnet_Profile, aspnet_Roles, aspnet_SchemaVersions, aspnet_Users, aspnet_UsersInRoles, aspnet_WebEvent_Events)
But I am using Application, User, Role, UserInRole, Profile tables only. Can I still migrate these table in order to use the ASP.NET Identity?
I'm ready to provide more information you may need to understand my current scenario.
I'm looking for the correct steps to migrate to Identity, any caution I need to take care, any hurdles I will face? Any help is highly appreciated.
Dave Paquette wrote this http://www.davepaquette.com/archive/2013/12/30/so-you-inherited-an-asp-net-web-forms-application.aspx
This may be the answer to your problem. Once you have integrated your Web Forms project to MVC, there are plenty of guides online to integrate the new Identity 2.0.
I'm new to ASP.NET MVC 4 framework, before I developed .NET web apps using ASP.NET Web Forms.
In my new project (I'm updating an existing Web Form project) I need to implement Form authentication and role based authorization to pages and functionalities.
Following some articles and StackOverflow answers I'm trying to use SimpleMembershipProvider but I'm finding several difficulties to configure it and in integration with my existing DB.
In particular cannot use my existing user accounts table...
I'm using SQL Server 2005 and now I'm upgrading from Linq-to-SQL to EntityFramework.
Can you suggest me the best way to implement authentication and role authorization in ASP.NET MVC4?
It depends how custom you need:
1) Try something, that exists already. As long as you're using EF, you may try https://efmembership.codeplex.com. Haven't tried it, but from first look, looks reasonable and configurable. There are also other MembershipProvider implementations on nuget gallery if previous one does not fit.
2) If really nothing fits into your scenario from existing in nuget gallery, implement membership provider by your self. Example may be here: http://blog.ianchivers.com/2012/03/entity-framework-custom-membership.html or there even video how to do it: http://www.asp.net/web-forms/videos/how-do-i/how-do-i-create-a-custom-membership-provider
I am developing an ASP .Net MVC 3 application using C# and SQL Server 2005.
I am using also Entity Framework and Code First Method.
I have an interface Login that works perfectly.
My problem that I have 3 Types of Users :
Root
Admin
User
and each one has a custom access to the pages of the application.
I search on the net and I found many tutos describing how to manage Roles but all are not using a database or using an existing database with ADO .NET, database first
My problem that I am using ENTITY FRAMEWORK and CODE FIRST.
This is what I have in my base . How can I bind this tables with my code ? I already used [Authorize] in some action and its works perfectly but now how I use [Authorize (Roles="Admin")] with my database.
It may be that you are looking for in the MVC custom role provider.
You can check this:
http://kitsula.com/Article/Custom-Role-Provider-for-MVC
https://codefirstmembership.codeplex.com/
http://techbrij.com/custom-roleprovider-authorization-asp-net-mvc
http://www.mattwrock.com/post/2009/10/14/Implementing-custom-Membership-Provider-and-Role-Provider-for-Authinticating-ASPNET-MVC-Applications.aspx
http://www.danharman.net/2011/06/23/asp-net-mvc-3-custom-membership-provider-with-repository-injection/
http://www.codeproject.com/Articles/165159/Custom-Membership-Providers
How to use Membership provider with EF Code First?
I have built an internal Database for Clients. Its C# with an MS-SQL DB. I have integrated the ASP Website SQL Server and the Internal SQL Server to use the one database. Both the Website and the Internal Database are working.
I want to be able to automatically register a client to use the webpage once they have become a Client in my Internal Database. Using ASP (I am learning still) I see there is a membership provider and it seems to do all the validation and so on. Passwords are all handled and encrypted etc..
What would be the best way to add a user to the SQL Tables but keep the security and so on? Can I create a membership provider in my DB Client when adding a Client and use that to create the Clients Login to the Web Page?
I am using the default ASP .NET Web Application Template in VS 2010. The ASP Site is all standard config from the template.
Thanks!
You should call the methods on the membership provider. Don't get into the specifics of how the membership provider is working, the whole point of the provider model is that you can swap out the default SQL one for any other implementation.
If you look at the MembershipProvider base class (http://msdn.microsoft.com/en-us/library/system.web.security.membershipprovider.aspx) you can see the list of methods that it provides. You will need to call Membership.CreateUser() as part of your custom registration process, it has several overloads to choose between.
Looking at the default SQL Config and stored proceedures, we can use these.
See this.
The sample code by Chris Pels is excellent for helping with this solution. Thanks Chris!