EF migration shows empty Up() Down() methods

后端 未结 17 2444
花落未央
花落未央 2020-12-25 09:56

I have a local database that is currently in it\'s second version and should now go to it\'s third version.

The code for the previous migrations was generated by ano

17条回答
  •  鱼传尺愫
    2020-12-25 10:02

    From the perspective of a complete Entity Framework (Core) beginner:

    1. Create your class which will become your table
      1. You can have subclasses with many-to-many or one-to-one relationships.
      2. In step 3 you see the context where both properties have a one-to-one relationship.
    2. Ensure you have one DbContext
      1. If you have more than one DbContext you need to specify which context you want to add the migration to with the -Context parameter.
    3. Add your class to your DbContext as shown by @CondingIntrigue
      1. As a reference The Entity Framework Core DbSet
    public class AccountContext : DbContext
    {
            public DbSet Accounts { get; set; }
            public DbSet SecretIdentity { get; set; }
    }
    
    1. Enter Add-Migration

提交回复
热议问题