Additional columns

Feb 6, 2012 at 8:29 PM

Hello, Omid, thanks for a great work!

I'm interested what is a recommended way to add say FullName column to the MembershipProvider?

I successfully configured this column to be generated in the database, but can't find a "clean" way to get my custom property returned.

Any suggestions?

 

Thanks,

Donatas

Coordinator
Feb 13, 2012 at 8:40 AM
Edited Feb 13, 2012 at 8:43 AM

Hi. you can see a example in source code:

Open "SourceDirectory\Default\OldEf\EfUser.cs" and  "EfUserMapper.cs"

First you need your custom MembershipUser class. ex:

 

[Serializable]
public class MyMembershipUser : System.Web.Security.MembershipUser { 
   
   public string FullName {get; set; }

}

 

then you need your custom mapper, because AutoMapper is not supporting custom column to custom property.

 

public class MyUserMapper : IUserMapper<EfUser> {
   ....
}

 

In your custom mapper you need to map your custom column to your additional property.

Then you must set your Custom mapper to you User/Role class:

[Table("Users")]
[EFDataMapper(typeof(MyUserMapper))]
public class MyUser { 
....
}