I found another solution if you have your user/authentication tables in a different schema than dbo (or whatever the default schema of the database user) and that's to use a view.
In my database, my user/authentication tables are scoped to a "Security" schema. I also have a Person schema where the Person table lives. I store just FirstName, LastName in Person table.
I created a view that pulls all of the tables together for authentication and am returning the following fields:
UserId, UserName, PersonId, FirstName, LastName, AuthenticationType, LastLoginDate, IsLockedOut
In my application, I can authenticate a person a number of different ways: Form, Windows, Facebook, Twitter, etc. The UserId, UserName relate to the different authentication type.
Here's my UserProfile class in ASP.Net MVC:
[Table("__vwRegisteredUser")]
public class UserProfile
{
[Key]
[DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
public int UserId { get; set; }
public String UserName { get; set; }
public int PersonId { get; set; }
public String FirstName { get; set; }
public String LastName { get; set; }
public String AuthenticationTypeName { get; set; }
public Boolean IsLockedOut { get; set; }
public DateTime LastLoginDate { get; set; }
public int Id
{
get
{
return PersonId;
}
}
public String Name
{
get
{
return String.Format("{0} {1}", FirstName, LastName);
}
}
}
Notice I use a view for the Table attribute. I'm also returning PersonId as an Id property and concatenating FirstName and LastName together as a Name property. The UserName is the value coming back from my Authentication Type (Windows user name, email address if I'm using Forms authentication, or whatever Facebook or Twitter returns). So, there's no consistency for UserName from my Security.Authentication table.
Initializing database connection still requires a table in order for SimpleMembership to generate membership tables. There maybe a way to have a custom membership table, but I haven't figured that out yet.