Search code examples
c#sql-serverasp.net-core.net-coreconnection-string

Connection string keyword 'server' is not Supported


I am deploying an ASP.NET Core MVC app with VS2017 on MacBook. When I want to update my database with

dotnet ef database update  --project MyProjectName

I get an error:

Connection string keyword 'server' is not supported. For a possible alternative, see https://go.microsoft.com/fwlink/?linkid=2142181.

I have installed System.Data.SqlClient package on my project and I have read similar questions but none of them solve my problem. What is the problem with this code? I am really getting confused.

"ConnectionStrings": {
    "DefaultConnection": "Server=my_ip; Database=my_db; User Id=sa; Password=my_pass;",
    "providerName": "System.Data.SqlClient"
  },
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning",
      "Microsoft.Hosting.Lifetime": "Information"
    }
  },
  "AllowedHosts": "*"
}

Solution

  • For SQL Server try this connection string:

    "DefaultConnection": "Data Source=35.xx.xx.xxxx;Initial Catalog=nmmm;Integrated Security=False;User ID=nmmm;Password=vvvvv;"
    

    add if you use sql server you should have this in startup

    services.AddDbContext<DbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));