2

Up to now, I can create Custom Membership Provider and Custom Role Provider, but I have problem with Custom Profile Provider. After looking at some demo, I've found out that they use web.config to define the schema for the Profile. For example, in the tag <profile>:

<properties> 
<add name="AddressName"/> 
<add name="AddressStreet"/> 
<add name="AddressCity"/> 
<add name="AddressState"/> 
<add name="AddressZipCode"/> 
<add name="AddressCountry"/> 
</properties>

To access that field, they use Profile.AddressName, Profile.AddressStreet, etc...

My question is: is that the only way to define the profile schema? If I want to use my UserProfile table in my database, what should I do? I need the way to read I write the data.

Thanks for your help.

Triet Doan
  • 11,455
  • 8
  • 36
  • 69
  • Why? So where do I store user's information? – Triet Doan Jul 22 '13 at 14:16
  • I prefer separating User table and Profile table. In User table, I only store information related to security, such as Username, Password, Email, etc... Maybe your idea is different from mine. Anyway, do you know the answer for my question? :) – Triet Doan Jul 22 '13 at 14:23
  • Yes, I know. But if I do that, what's the usage of custom profile provider? – Triet Doan Jul 22 '13 at 14:37

1 Answers1

0

Probably not much of use to the original poster, but it looks like you can do as described in this blog post. The gist is that you let the generated profile class inherit your own class which in turn inherits from ProfileBase, and finally override ProfileProvider:

    <profile inherits="Acme.MyApplication.ProfileCommon,MyApplication" defaultProvider="EfTableProfileProvider">
      <providers>
        <clear />        
        <add name="EfTableProfileProvider" type="Acme.MyApplication.EfTableProfileProvider,Facade" connectionStringName="ApplicationServices" applicationName="/MyApplication"/>
      </providers>
    </profile>
Bouke
  • 11,768
  • 7
  • 68
  • 102