Answer the question
In order to leave comments, you need to log in
The database is not created (ASP.NET Core + EF Core), what's the problem?
in appsettings
"ConnectionStrings": {
"DefaultConnection": "Server=(LocalDb)\\MSSQLLocalDB; Database=test; Trusted_Connection=True;"
},
public void ConfigureServices(IServiceCollection services)
{
services.AddControllersWithViews();
string connection = Configuration.GetConnectionString("DefaultConnection");
services.AddDbContext<AppDbContext>(x => x.UseSqlServer(connection));
}
public DbSet<People> Peoples { get; set; }
public AppDbContext(DbContextOptions<AppDbContext> options)
: base(options)
{
Database.EnsureCreated();
}
Answer the question
In order to leave comments, you need to log in
What's wrong? However, it universally helps to type in the package console Add-migration initial
Update-database
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question