locked
Value cannot be null. (Parameter 'connectionString') RRS feed

  • Question

  • User-605499000 posted

    Hi,

    I am trying to link to my database. I am using aspnet.core 3.0 mvc.  I am using nu-get console and getting the above error.

    Below is the appsettings.json:

    "ConnectionStrings": {
    "BumplesDBConnection": "Server=(localdb)\\mssqllocaldb;Database=aspnet-Bumples;Trusted_Connection=True;MultipleActiveResultSets=true"
    },

    Below is the startup:

    public void ConfigureServices(IServiceCollection services)
    {
    services.AddControllersWithViews();

    services.AddDbContext<ApplicationDbContext>(options =>
    options.UseSqlServer(
    Configuration.GetConnectionString("DefaultConnection")));
    services.AddScoped<IMembersRepository, SQLMembersRepository>();

    }

    Below is the start of the error that I got in the console.

    Build started...
    Build succeeded.
    System.ArgumentNullException: Value cannot be null. (Parameter 'connectionString')
    at Microsoft.EntityFrameworkCore.Utilities.Check.NotEmpty(String value, String parameterName)
    at Microsoft.EntityFrameworkCore.SqlServerDbContextOptionsExtensions.UseSqlServer(DbContextOptionsBuilder optionsBuilder, String connectionString, Action`1 sqlServerOptionsAction)
    at Bumples.Startup.<ConfigureServices>b__4_0(DbContextOptionsBuilder options) in C:\Users\Jennifer E Sheehan\source\repos\Bumples\Startup.cs:line 33
    at Microsoft.Extensions.DependencyInjection.EntityFrameworkServiceCollectionExtensions.<>c__DisplayClass1_0`2.<AddDbContext>b__0(IServiceProvider p, DbContextOptionsBuilder b)
    at Microsoft.Extensions.DependencyInjection.EntityFrameworkServiceCollectionExtensions.CreateDbContextOptions[TContext](IServiceProvider applicationServiceProvider, Action`2 optionsAction)
    at Microsoft.Extensions.DependencyInjection.EntityFrameworkServiceCollectionExtensions.<>c__DisplayClass10_0`1.<AddCoreServices>b__0(IServiceProvider p)
    at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitFactory(FactoryCallSite factoryCallSite, RuntimeResolverContext context)
    at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
    at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType)
    at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScopeCache(ServiceCallSite singletonCallSite, RuntimeResolverContext context)
    at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)

    Hope someone can help me, Thanks,

    Jen

    Wednesday, March 25, 2020 9:44 PM

Answers

  • User-605499000 posted

    I put back default connection and know I am getting errors that I think I can fix. Thank you for getting back to me so fast.

    Jen

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, March 26, 2020 12:27 AM

All replies

  • User-474980206 posted

    where is DefaultConnection defined in app.settings

    Wednesday, March 25, 2020 10:03 PM
  • User-605499000 posted

    I took out default connection and put in what was recommended by one tutorial that I am taking.  Should I put DefaultConnection instead of BumplesConnection.

    Jen

    Thursday, March 26, 2020 12:03 AM
  • User-605499000 posted

    I put back default connection and know I am getting errors that I think I can fix. Thank you for getting back to me so fast.

    Jen

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, March 26, 2020 12:27 AM