I am trying to generate a connection to the database in ASP.NET Core MVC, but when trying to enter the index page of my miles controller, it generates an error, because the connection to the database has not been made.
This is my appsettings.json
:
"ConnectionStrings": {
"MillaContext": "Server=server;Database=Bit_V2;User Id=sa; Password=password;Trusted_Connection=True;MultipleActiveResultSets=true"
}
This is my startup.cs:
public void ConfigureServices(IServiceCollection services)
{
...
services.AddDbContext<MillaContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("MillaContext")));
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
}
And this is error: