lucky panthagani
lucky panthagani

Reputation: 23

Why new table not created in sql database after migration in mvc codefirst

Run the command Enable-Migrations

Add-Migration X with X being whatever name you want to give this migration

But After this migration if i create any new Table why its not Generated in db

Upvotes: 1

Views: 2102

Answers (1)

Antonio
Antonio

Reputation: 251

after creating your class need to set the table in the dbcontext like:

public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
    {
    public DbSet<User> User {get;set;}
    }


public class User
{
    [key]
    public int id {get;set;}
    public string name {get;set;}
}

create the migration and update the database

Upvotes: 1

Related Questions