Home > Net >  C# .NET SQL SERVER singlar.net appsettings.json
C# .NET SQL SERVER singlar.net appsettings.json

Time:11-14

I have just started working with singlar.net and i came across this code but i dont know how to find out "your connection string" in the appsettings.json.

Please can someone help me with this!?


{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft.AspNetCore": "Warning"
    }
  },
  "AllowedHosts": "*",
  "ConnectionStrings": {
    "SqlServer": "Your connection string"
  }
}

set a connection string for the database

CodePudding user response:

To get a connection string from your config, you can use IConfiguration.GetConnectionString(...).

Example: configuration.GetConnectionString("SqlServer")

CodePudding user response:

To find out your connection string you need to know

  1. It´s hostname or ip
  2. What "brand" of DBMS (Database Management System) you are dealing with (MS SQL, SQLite, Oracle etc.)
  3. How you can provide authentication (Windows authentication or user name & password or...)

If you´ve got this, there´s a couple of ways to find out how the connection string is supposed to look like, depending on the tools available to you.

In VS for example you can go to Tools->Connect to database and enter your connection info:

Add Connection

Then go to View->Server browser, right click your server and select Properties. There you can find your connection string.

You always have the option to just "build" your connection string manually if you know how it should look. Sites like ConnectionStrings.com can be of help here.

  • Related