1

I want to create a new datatable in my database. I ran Add-Migration items, it shows empty for both up() and down()

namespace myapp.Migrations
{
using System;
using System.Data.Entity.Migrations;

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

    public override void Down()
    {
    }
}
}

I have a model:

public class Item
{
    public string name { get; set; }

    public int defineindex { get; set; }
}

public class ItemContext : DbContext
{
    public DbSet<Item> Items { get; set; }
} 

I also created a mapping when the above code doesnt generate useful scaffold. But it still didnt solve my problem.

Zhao Chen
  • 19
  • 1
  • 3
  • Did you build before you ran add-migrations? and have you configured an Id field for he item class? ef likes it if you have an id field in the class – Lewis Taylor Oct 16 '15 at 20:09
  • I built before ran add-migrations. I tried to add "public int Id { get; set; }" but still getting the same empty up/down. – Zhao Chen Oct 16 '15 at 20:19

1 Answers1

0

There is a ContextKey value in my Migrations/Configuration.cs for my EF, which is set to a class name. So my EF will only care about that class. I need to put my DbSets all under that class for it to work instead of creating a new class.

Zhao Chen
  • 19
  • 1
  • 3