0
"ConnectionStrings": {
"DefaultConnection": "Server=(localdb)\\mssqllocaldb; Database=ABC; Trusted_Connection=True; MultipleActiveResultSets=true"}

I am working with ASP.NET Core MVC. I have this connection string in my appsettings.json file but it doesn't seem to work. While running "dotnet ef database update" from cmd, I am getting this error keyword not supported: 'server.'. What's wrong with it?

8
  • Is it true to assume, you're using EntityFramework for this connection ? Commented Mar 3, 2018 at 18:47
  • That is not an EF connection string Commented Mar 3, 2018 at 18:47
  • 1
    Possible duplicate of Keyword not supported: 'server' Commented Mar 3, 2018 at 18:49
  • @Nkosi, I know, that is why i'm trying to know if the OP is using it with EF which will explain the error. Commented Mar 3, 2018 at 18:50
  • Yes, I am using EF Commented Mar 3, 2018 at 18:50

2 Answers 2

6

Apologies! In my ConfigureServices method in Startup.cs, I was using SQLite database provider

services.AddDbContext<ApplicationDbContext>(options => options.UseSqlite(Configuration.GetConnectionString("DefaultConnection")))

I changed it to the following, and it worked with my connection string.

services.AddDbContext<ApplicationDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")))
Sign up to request clarification or add additional context in comments.

Comments

-4

The connection string should start of with Data Source=.

In Visual Studio if you open the SQL Server Object Explorer and click on the database you are wanting to connect to. The connection string will be displayed in the Properties window. The connections string should look something like this for localDb

Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=DbName;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=Fals

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.