I was studying this tutorial asp.net Movie Tutorial and I have 2 simple files in my model.
public class Movie
{
public int ID { get; set; }
[Required]
public string Title { get; set; }
}
public class MovieDBContext : DbContext
{
public DbSet<Movie> Movies { get; set; }
}
And the other one is the Account Model that Visual Studio gives me :
public class UsersContext : DbContext
{
public UsersContext()
: base("DefaultConnection")
{
}
public DbSet<UserProfile> UserProfiles { get; set; }
}
[Table("UserProfile")]
public class UserProfile
{
[Key]
[DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
public int UserId { get; set; }
public string UserName { get; set; }
}
The problem is.... If I add a propety
public int aaa { get; set; }
to the UserProfile class, I get no changes in the migration....This happens because the migration only updates class that are inside the MovieDBContext.... So I must add something like:
public class MovieDBContext : DbContext
{
public DbSet<Movie> Movies { get; set; }
public DbSet<UserProfile> User{get;set}
}
The problem is that in another project I am trying to update the AccountModel and tried this solution but it didnt work.... Does anyone know another solution?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…