I added a new class and field to an existing one, and now I want to start the migration. I add "add-migration addUsers" but an empty file is generated. What could be the problem?

public partial class addUsers : DbMigration { public override void Up() { } public override void Down() { } } 

Existing class

 public class Task { public int Id { get; set; } [Required(ErrorMessage = "Title is required.")] public string Title { get; set; } [Required] public string Author { get; set; } [Required] public string Description { get; set; } public UserProfile Owner { get; set; } //<- Добавил это поле } 

New class

 public class UserProfile { public int Id { get; set; } public string UserName { get; set; } public ICollection<Task> Tasks { get; set; } } 

DBSets

 public class TasksDatabase : DbContext { public TasksDatabase() : base("eTask") { } public DbSet<Task> Tasks { get; set; } public DbSet<UserProfile> UserProfiles { get; set; } } 

last migration

 public override void Up() { CreateTable( "dbo.Tasks", c => new { Id = c.String(nullable: false, maxLength: 128), Title = c.String(nullable: false, maxLength: 256), Author = c.String(nullable: false, maxLength: 256), Description = c.String(nullable: true) }) .PrimaryKey(t => t.Id) .Index(t => t.Name, unique: true, name: "NameIndex"); } public override void Down() { DropIndex("dbo.Tasks", "NameIndex"); } 
  • And what changes in the database do you expect? - Pavel Mayorov
  • @PavelMayorov Adding a new field to the Tasks table. And adding a new UserProfile table. - Maksims
  • Did you remember to add DbSet? - Pavel Mayorov
  • By the way, is there a new field in the database and the table already exists? - Pavel Mayorov
  • @PavelMayorov DBSet added. Not. It will not appear until I update-database - Maksims

0