0

コード ファースト ベースの mvc4 アプリケーションを Azure にデプロイしようとすると、いくつかの問題が発生します。

localdb を作成するときは正常に動作しますが、UserProfile テーブルを Azure に展開しようとすると、Username と UserId フィールドのみが作成されます。

私のモデルは次のようになります

[Table("UserProfile")]
public class UserProfile
{
    [Key]
    [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
    public int UserId { get; set; }

    public Guid ConsumerId { get; set; }
    public string UserName { get; set; }
    public string FirstName { get; set; }
    public string LastName { get; set; }
    public string Email { get; set; }
    public bool IsMale { get; set; }
    public string Mobile { get; set; }
    [DefaultValue(false)]
    public bool IsSmsVerified { get; set; }
    public string SmsVerificationCode { get; set; }

}

環境

  public class UsersContext : DbContext
{
    public UsersContext()
        : base("DefaultConnection")
    {
    }

    public DbSet<UserProfile> UserProfiles { get; set; }
    public DbSet<ExternalUserInformation> ExternalUsers { get; set; }
}

構成

 internal sealed class Configuration : DbMigrationsConfiguration<Web.Models.UsersContext>
{
    public Configuration()
    {
        AutomaticMigrationsEnabled = true;
    }

    protected override void Seed(Web.Models.UsersContext context)
    {
        //  This method will be called after migrating to the latest version.

        //  You can use the DbSet<T>.AddOrUpdate() helper extension method 
        //  to avoid creating duplicate seed data. E.g.
        //
        //    context.People.AddOrUpdate(
        //      p => p.FullName,
        //      new Person { FullName = "Andrew Peters" },
        //      new Person { FullName = "Brice Lambson" },
        //      new Person { FullName = "Rowan Miller" }
        //    );
        //

        WebSecurity.InitializeDatabaseConnection("DefaultConnection", "UserProfile", "UserId", "UserName", autoCreateTables: true);

オンにする必要がある魔法のスイッチがどこかにありますか?

4

0 に答える 0