I am working on an ASP.NET MVC Application with authentication and I want to use my own Profile table instead of the usual ASP.NET Profile table with Property Values / Property Names.
My Profile table uses SQL columns and it might be related with other columns.
I am using Entity Framework and I think ASP.NET Membership is limitative.
I have been a lot of problems with the MembershipUser objects and Profile provider and building models from it for my views, as well as updating users, etc.
1. Does anyone here uses its own Membership system and not the ASP.NET one?
2. Is it possible to use Forms Authentication but keep the maintenence of my tables all by my own UserService which mantains Users, Profiles, Roles, ... ?
2. Is it possible to use Forms Authentication but keep the maintenence of my tables all by my own UserService which mantains Users, Profiles, Roles, ... ?
The buil-in provider makes use of cookie value to implement Forms authentication by default. If you don't want to set up this feature from scratch, the best idea is to create your own membership provider by inheriating from default SqlMembershipProvider.
And just change the table name, column name and stored procedure used by it to conform to your own database schema.
I agree that ASP .Net Membership can be limited at times, especially with the need for Microsoft SQL.
If you wanted to use Entity Framework and a custom ASP .Net Membership/Profile/Role Provider, the following link is probably what you are looking for:
http://www.codeproject.com/KB/aspnet/AspNetEFProviders.aspx. It provides a membership/profile/role system that uses entity framework and it should not be very difficult to integrate
it into your own application. It also continues to integrate with Forms Authentication as normal. You would just be replacing the system by which ASP .Net stores the data.
Hope that helps. Let me know if you have any further questions.
Hope that helps. Let me know if you have any further questions.
Yes, I have been looking at that for the past days and it is the way I think I will follow but
there is a problem:
The usual Profile Property Names / Property Values way of storing profile data is not very nice.
I would like my Profile Table to have normal SQL columns and probably even related to other tables.
I already have my tables and my ProfileRepository which returns a Profile object from those tables.
My problem is how to integrate this with Profile Provider.
If I could do this with the Custom EF providers then it would be great.
Thanks,
Miguel
Well, the code from the link doesn't directly support a profile table with normal SQL columns, but you can probably modify it to do so. If you were interested, this link
http://www.asp.net/downloads/sandbox/table-profile-provider-samples/ has a sample Profile provider, which does what you were looking for, but I'm not sure how well it would integrate
with the EF providers.
If you did want to modify the custom EF Providers to use your custom Profile table, you would probably have to modify it quite extensively as the whole structure changes and serialization would no longer be needed (I assume). What you would probably have
to do is create a way of dynamically accessing properties in the Profile object to return the various properties. It may be better just to rely on plain old fashioned SQL queries, as that would be more suited for this type of thing.
What about using the EF Membership and Role providers and drop the Profile provider.
For profiler I could access directly my Profile repository.
I think everything that is important for the sistem is made by the Roles and Membership provider.
I can create a MembershipService that uses those two providers for Membership and Roles and that accesses the Profile repository for operations with profile.
Then on my application I just access the Membership service.
What about using the EF Membership and Role providers and drop the Profile provider.
For profiler I could access directly my Profile repository.
I think everything that is important for the sistem is made by the Roles and Membership provider.
I can create a MembershipService that uses those two providers for Membership and Roles and that accesses the Profile repository for operations with profile.
Then on my application I just access the Membership service.
There shouldn't be a problem with droping the Profile provider. The ability to plug-in different providers without affecting anything else was one of the goals of the provider architecture.
Does that mean if i want to add other columns to the membershipuser table, i have to update the entity, the stored procedures and the data access layers?
shapper
Contributor
3932 Points
3789 Posts
Membership and ASP.NET MVC
Aug 06, 2009 01:52 AM|LINK
Hello,
I am working on an ASP.NET MVC Application with authentication and I want to use my own Profile table instead of the usual ASP.NET Profile table with Property Values / Property Names.
My Profile table uses SQL columns and it might be related with other columns.
I am using Entity Framework and I think ASP.NET Membership is limitative.
I have been a lot of problems with the MembershipUser objects and Profile provider and building models from it for my views, as well as updating users, etc.
1. Does anyone here uses its own Membership system and not the ASP.NET one?
2. Is it possible to use Forms Authentication but keep the maintenence of my tables all by my own UserService which mantains Users, Profiles, Roles, ... ?
Any help is welcome.
Thanks,
Miguel
rxwen
Member
512 Points
71 Posts
Re: Membership and ASP.NET MVC
Aug 06, 2009 02:30 AM|LINK
There are some resources out there explain the mechanism of membership system and how to write your own one to replace the builtin provider:
http://msdn.microsoft.com/en-us/library/aa479048.aspx
http://msdn.microsoft.com/en-us/library/ms998347.aspx
http://www.4guysfromrolla.com/articles/120705-1.aspx
The buil-in provider makes use of cookie value to implement Forms authentication by default. If you don't want to set up this feature from scratch, the best idea is to create your own membership provider by inheriating from default SqlMembershipProvider. And just change the table name, column name and stored procedure used by it to conform to your own database schema.
surrealdolph...
Member
48 Points
12 Posts
Re: Membership and ASP.NET MVC
Aug 06, 2009 02:32 AM|LINK
I agree that ASP .Net Membership can be limited at times, especially with the need for Microsoft SQL.
If you wanted to use Entity Framework and a custom ASP .Net Membership/Profile/Role Provider, the following link is probably what you are looking for: http://www.codeproject.com/KB/aspnet/AspNetEFProviders.aspx. It provides a membership/profile/role system that uses entity framework and it should not be very difficult to integrate it into your own application. It also continues to integrate with Forms Authentication as normal. You would just be replacing the system by which ASP .Net stores the data.
Hope that helps. Let me know if you have any further questions.
shapper
Contributor
3932 Points
3789 Posts
Re: Membership and ASP.NET MVC
Aug 06, 2009 11:48 AM|LINK
Yes, I have been looking at that for the past days and it is the way I think I will follow but there is a problem:
The usual Profile Property Names / Property Values way of storing profile data is not very nice.
I would like my Profile Table to have normal SQL columns and probably even related to other tables.
I already have my tables and my ProfileRepository which returns a Profile object from those tables.
My problem is how to integrate this with Profile Provider.
If I could do this with the Custom EF providers then it would be great.
Thanks,
Miguel
surrealdolph...
Member
48 Points
12 Posts
Re: Membership and ASP.NET MVC
Aug 06, 2009 06:02 PM|LINK
Well, the code from the link doesn't directly support a profile table with normal SQL columns, but you can probably modify it to do so. If you were interested, this link http://www.asp.net/downloads/sandbox/table-profile-provider-samples/ has a sample Profile provider, which does what you were looking for, but I'm not sure how well it would integrate with the EF providers.
If you did want to modify the custom EF Providers to use your custom Profile table, you would probably have to modify it quite extensively as the whole structure changes and serialization would no longer be needed (I assume). What you would probably have to do is create a way of dynamically accessing properties in the Profile object to return the various properties. It may be better just to rely on plain old fashioned SQL queries, as that would be more suited for this type of thing.
For dynamically accessing properties, e.g. to get value of the property "address" from the Profile object, you could probably use some code like: http://www.vcskicks.com/properties.php if you weren't too worried about performance. Otherwise, something like http://www.codeproject.com/KB/cs/fast_dynamic_properties.aspx would be faster but a bit more complicated.
shapper
Contributor
3932 Points
3789 Posts
Re: Membership and ASP.NET MVC
Aug 06, 2009 07:02 PM|LINK
What about using the EF Membership and Role providers and drop the Profile provider.
For profiler I could access directly my Profile repository.
I think everything that is important for the sistem is made by the Roles and Membership provider.
I can create a MembershipService that uses those two providers for Membership and Roles and that accesses the Profile repository for operations with profile.
Then on my application I just access the Membership service.
surrealdolph...
Member
48 Points
12 Posts
Re: Membership and ASP.NET MVC
Aug 07, 2009 05:41 AM|LINK
There shouldn't be a problem with droping the Profile provider. The ability to plug-in different providers without affecting anything else was one of the goals of the provider architecture.
motif8
Member
2 Points
1 Post
Re: Membership and ASP.NET MVC
Aug 14, 2009 01:47 AM|LINK
Oops! Upon re-reading I realize this was suggested already. Nevermind!
Perhaps the Profile Provider found at http://www.asp.net/downloads/sandbox/table-profile-provider-samples/ would work for you.
sjnaughton
All-Star
27330 Points
5459 Posts
MVP
Re: Membership and ASP.NET MVC
Aug 14, 2009 08:41 PM|LINK
see http://www.asp.net/learn/videos/video-189.aspx for a short video on how to create your own membership provider (it is in VB though [:(] )
MVC membership provider
Always seeking an elegant solution.
hell666
Member
38 Points
65 Posts
Re: Membership and ASP.NET MVC
Apr 29, 2010 01:11 AM|LINK
Does that mean if i want to add other columns to the membershipuser table, i have to update the entity, the stored procedures and the data access layers?