An unhandled exception occurred while processing the request. ArgumentException: Keyword not supported: 'service'

Viewed 289

I have an asp.net core MVC application and I get an error after scaffolding.

My connection string is as follows appsettings.json

"ConnectionStrings": {
    "MyNewDatabase": "data source=.; initial catalog=MyNewDb; integrated security=true"
  }

And the error I encountered:

> ArgumentException: Keyword not supported: 'service'.

I take it to the comment line in Startup.cs because if I don't take it to the comment line, it gives an error here

> app.UseMvc(routes => {
>                 routes.MapRoute(
>                 name: "default",
>                 template: "{Controller=Home}/{action=Index}");
>             });
1 Answers

I changed the following code in Startup.cs

> app.UseEndpoints(endpoints =>
>             {
>                 endpoints.MapControllerRoute(
>                     name: "default",
>                     pattern: "{controller=Home}/{action=Index}/{id?}");
>             });

And I added the following code in AppDbContext.cs

optionsBuilder.UseSqlServer(@"data source=.; initial catalog=MyNewDb; integrated security=true");
Related