0
votes
"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?

2
Is it true to assume, you're using EntityFramework for this connection ? - Orel Eraki
That is not an EF connection string - Nkosi
Possible duplicate of Keyword not supported: 'server' - Nkosi
@Nkosi, I know, that is why i'm trying to know if the OP is using it with EF which will explain the error. - Orel Eraki
Yes, I am using EF - Vista

2 Answers

6
votes

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")))
-4
votes

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