how to connect asp.net core MVC project to local DB using Entity Framework Core on ubuntu desktop

asp.net-core c# entity-framework-core sql-server ubuntu-16.04

Question

I'm Building an asp.net core application using Entity Framework Core on Ubuntu 16.04 desktop. I have SQL Server installed and running. I've run the command "-dotnet ef migrations Initial" successfully. I'm prepared to run "-dotnet ef database update" to allow EF to connect to and create the table in the database but I'm receiving this error on the terminal:

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 25 - Connection string is not valid)

it's a local DB so I'm thinking I don't need a TCP provider, right? how do I tell EF to connect to SQL server?

1
1
7/27/2017 4:39:09 PM

Accepted Answer

Specify your connection string on appsettings.json file

{
  "ConnectionStrings": {
    "DefaultConnection": "Server=YOUR_SERVER_NAME;Database=DBNAME;User Id=sa;Password=PASSWORD;Trusted_Connection=True;MultipleActiveResultSets=true"
  },
  "Logging": {
    "IncludeScopes": false,
    "LogLevel": {
      "Default": "Warning"
    }
  }
}
2
7/28/2017 6:20:04 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow