I am studying .Net Core 2 and I am not able to connect to the database.
My appsettings.json looks like this:
"ConnectionStrings": {
"DefaultConnection": "Server=FAYOL\SQLEXPRESS;Database=Pagamento;Trusted_Connection=True;MultipleActiveResultSets=true"
},
And the Startup.cs
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Repository;
namespace Radix
{
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
var connection = @"Server=FAYOL\SQLEXPRESS;Database=Pagamento;Trusted_Connection=True;ConnectRetryCount=0";
services.AddDbContext<Contexto>(options => options.UseSqlServer(connection));
}
}
}
I'm not sure how to point Startup.cs
to Json and how to do that. I took an example on the internet that puts the string right in ConfigureServices
(like the example above) and is giving error.
Can you help me?
Thank you