シンプルメンバーとテーブルに問題があります。 WebSecurityでCreateUserAndAccount
メソッドを使用してユーザーを作成します。テーブルに追加のフィールドを作成できません。Simplemembership
ただし、テーブルに追加のフィールドがないため、アプリケーションを実行するとエラーが発生します。
WebSecurity.InitializeDatabaseConnection("ChatContext", "Users", "UserID", "Username",autoCreateTables:true);
これらのフィールドをコードを使用して既存のテーブルに追加できますか?
public class ChatContext : DbContext
{
public ChatContext(): base("ChatContext")
{
}
public DbSet<UserModel> Users { get; set; }
public DbSet<VoteModel> Votes { get; set; }
}
UserModel:
[Table("Users")]
public class UserModel
{
[Key]
public string UserID { get; set; }
public string Username { get; set; }
public string Email { get; set; }
public int Age { get; set; }
public string Country { get; set; }
public string NativeLanguage { get; set; }
public string LanguageToLearn { get; set; }
public float Vote { get; set; }
}
のApplication_Start()残念ながら、テーブルが作成されていない
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
Database.SetInitializer(new CreateDatabaseIfNotExists<ChatContext>());
WebSecurity.InitializeDatabaseConnection("ChatContext", "Users", "UserID", "Username",autoCreateTables:true);
}
私は、コンテキストを作成します。 ユーザーテーブルにこれらの追加フィールドを追加する方法を教えてもらえますか?
移行の詳細https://msdn.microsoft.com/en-us/data/dn579398.aspx?f=255&MSPPError=-2147217396 –