Here is my code:
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<AppDbContext>(options =>
{
options.UseSqlServer(Configuration.GetConnectionString("AppDbContext"));
});
services.AddMvc();
}
And this is my DbContext:
public class AppDbContext : DbContext
{
public AppDbContext(DbContextOptions<AppDbContext> options) : base(options)
{
}
public DbSet<Actor> Actors { get; set; }
public DbSet<Movie> Movies { get; set; }
public DbSet<MovieActor> MovieActors { get; set; }
}
And my ConnectionString is just fine. I'm really wondering why my DB is not generating when I run this code? The breakpoint is hitting in the line services.AddDbContext
but when I put a breakpoint in AppDbContext
it is not hitting. Can anybody help? My code exactly is looks like this https://learn.microsoft.com/en-us/aspnet/core/data/ef-mvc/intro