Network Error While updating database in Visual Studio Nugget package manager

  Kiến thức lập trình

im new to dotnet and as i was watching a tutarial on Blazor Wasm with Cookie authentiaction ,im getting this error after i ran update-databse in the console.

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 – Could not open a connection to SQL Server).

are there any additional tools or programs i need to install on my machine or is this error related to my project? how can i solve this?

  public class Program
  {
      public static void Main(string[] args)
      {
          var builder = WebApplication.CreateBuilder(args);

          // Add services to the container.
          builder.Services.AddRazorComponents().AddInteractiveWebAssemblyComponents();

          builder.Services.AddDbContext<ApplicationDbContext>(o =>
              o.UseSqlServer(builder.Configuration.GetConnectionString("Default"))
          );

          builder
              .Services.AddIdentity<ApplicationUser, IdentityRole>()
              .AddEntityFrameworkStores<ApplicationDbContext>()
              .AddSignInManager()
              .AddDefaultTokenProviders();
          ;

          var app = builder.Build();

          // Configure the HTTP request pipeline.
          if (app.Environment.IsDevelopment())
          {
              app.UseWebAssemblyDebugging();
          }
          else
          {
              app.UseExceptionHandler("/Error");
              // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
              app.UseHsts();
          }

          app.UseHttpsRedirection();

          app.UseStaticFiles();
          app.UseAntiforgery();

          app.MapRazorComponents<App>()
              .AddInteractiveWebAssemblyRenderMode()
              .AddAdditionalAssemblies(typeof(Client._Imports).Assembly);

          app.Run();
      }
  }
<PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>



<ItemGroup>
    <ProjectReference Include="..Safrim.Wasm.ClientSafrim.Wasm.Client.csproj" />
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="8.0.6" />
    <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.7" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.7" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.7">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
</ItemGroup>

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT