Jak utworzyć niestandardowe dodatkowe pola w UserProfile w MVC4
Miałem do czynienia z nową funkcją ASP MVC 4, która została dostarczona z nowym schematem db członkostwa i nową inicjalizacją. W mvc 3 i starsze wersje programista mógł tworzyć niestandardowe pola profilu użytkownika przy użyciu specyfikacji w pliku web.config, ale teraz zmierzyłem się z metodą w przestrzeni nazw filtrów w domyślnym projekcie mvc 4:
WebSecurity.InitializeDatabaseConnection("DefaultConnection", "UserProfile", "UserId", "UserName", autoCreateTables: true);
i tabela profilu użytkownika:
[Table("UserProfile")]
public class UserProfile
{
[Key]
[DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
public int UserId { get; set; }
public string UserName { get; set; }
}
Ale metoda InitializeDatabaseConnection generuje tylko UserName i UserId potrzebuję wygenerować inne dodatkowe pola.
Mam dobre doświadczenie w podejściu EF codeFirst iw tym przypadku próbuję edytować klasę UserProfile:
[Table("UserProfile")]
public class UserProfile
{
[Key]
[DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
public int UserId { get; set; }
[Column]
[Required]
public string UserName { get; set; }
[Column]
[Required]
public string FirstName { get; set; }
[Column]
[Required]
public string LastName { get; set; }
}
Ale kiedy regeneruję bazę danych, nie widziałem żadnych zmian, Nie wygenerowano niestandardowych pól Db. Pomóż mi, jak mogę utworzyć niestandardowe pola użytkownika?