Migration generated empty after Scaffolding

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 generated via Scaffolding, Controller and Views , I'm using Entity Framework.

However, when you run the command Add-Migratin it generates a file with no changes:

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

    public override void Down()
    {
    }
}

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

    
asked by anonymous 16.02.2017 / 15:53

1 answer

3

The problem has nothing to do with Scaffolding.

Certainly we just need to add the model in context.

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

public class Contexto : DbContext
{
    public DbSet<RelatorioTagModels> RelatorioTagModels { get; set; }
}
    
16.02.2017 / 16:45