Empty generated migration after Scaffolding

Asked

Viewed 220 times

0

I’m studying ASP.NET MVC5, so I created a model called RelatorioTagModels:

 public class RelatorioTagModels
{
    [Key]
    public int TagID { get; set; }

    [Required]
    public decimal Tag { get; set; }
    [Required]
    public decimal Fabricante { get; set; }
    [Required]
    public decimal Modelo { get; set; }
    [Required]
    public decimal Fluido { get; set; }
    [Required]
    public decimal Vedacao { get; set; }
    [Required]
    public decimal Criticidade { get; set; }
    [Required]       
    public decimal Mtbf { get; set; }
}

I managed via Scaffolding, the Controller and the Views, am using Entity Framework.

However, when rotating the command Add-Migratin it generates a file without changes:

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

    public override void Down()
    {
    }
}

My question is, how do I set the table in the database?

1 answer

3


The problem has nothing to do with Scaffolding.

Certainly just need to add the model in context.

In the project there must be a class that inherits from DbContext. This class must contain all models referenced.

public class Contexto : DbContext
{
    public DbSet<RelatorioTagModels> RelatorioTagModels { get; set; }
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.