Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Connection string for named instance #4996


User avatar
0
sumitshah created

Have setup SQL Server 2016 standard edition on my local machine and added the below connection string in the appsettings.json file:

"Default": "Server=SUMITSH-W10\SQL2016; Database=IDMS_vNext_AspNetZero; Trusted_Connection=True;"

If, am not using the named instance of DB, the code works as desired and am able to connect with the DB.

"Default": "Server=SUMITSH-W10; Database=Dw_Admin_AspNetZero_Schema; Trusted_Connection=True;"

Not sure, if defining the connection string for the named instance correctly.

This is giving me error as below:

An error occurred while starting the application.

SqlException: Invalid object name 'AbpEditions'.

System.Data.SqlClient.SqlConnection.OnError(SqlException exception, bool breakConnection, Action<Action> wrapCloseInAction)

SqlException: Invalid object name 'AbpEditions'.

System.Data.SqlClient.SqlConnection.OnError(SqlException exception, bool breakConnection, Action<Action> wrapCloseInAction)

System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, bool breakConnection, Action<Action> wrapCloseInAction)

System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, bool callerHasConnectionLock, bool asyncClose)

System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, out bool dataReady)

System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()

System.Data.SqlClient.SqlDataReader.get_MetaData()

System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, string resetOptionsString)

System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, bool returnStream, bool async, int timeout, out Task task, bool asyncWrite, SqlDataReader ds)

System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, bool returnStream, TaskCompletionSource<object> completion, int timeout, out Task task, bool asyncWrite, string method)

System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior)

System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)

System.Data.Common.DbCommand.ExecuteReader()

Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.Execute(IRelationalConnection connection, DbCommandMethod executeMethod, IReadOnlyDictionary<string, object> parameterValues)

Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.ExecuteReader(IRelationalConnection connection, IReadOnlyDictionary<string, object> parameterValues)

Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable+Enumerator.BufferlessMoveNext(bool buffer)

Microsoft.EntityFrameworkCore.Storage.Internal.SqlServerExecutionStrategy.Execute<TState, TResult>(TState state, Func<DbContext, TState, TResult> operation, Func<DbContext, TState, ExecutionResult<TResult>> verifySucceeded)

Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable+Enumerator.MoveNext()

System.Linq.Enumerable.TryGetFirst<TSource>(IEnumerable<TSource> source, out bool found)

lambda_method(Closure , QueryContext )

Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler+<>c__DisplayClass17_1.<CompileQueryCore>b__0(QueryContext qc)

Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.Execute<TResult>(Expression query)

Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryProvider.Execute<TResult>(Expression expression)

System.Linq.Queryable.FirstOrDefault<TSource>(IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate)

Infogroup.IDMS.Migrations.Seed.Host.DefaultEditionCreator.CreateEditions() in DefaultEditionCreator.cs + 26. var defaultEdition = _context.Editions.IgnoreQueryFilters().FirstOrDefault(e => e.Name == EditionManager.DefaultEditionName);

Infogroup.IDMS.Migrations.Seed.Host.DefaultEditionCreator.Create() in DefaultEditionCreator.cs + 21. CreateEditions();

Infogroup.IDMS.Migrations.Seed.Host.InitialHostDbBuilder.Create() in InitialHostDbBuilder.cs + 16. new DefaultEditionCreator(_context).Create();

Infogroup.IDMS.Migrations.Seed.SeedHelper.SeedHostDb(IDMSDbContext context) in SeedHelper.cs + 26. new InitialHostDbBuilder(context).Create();

Infogroup.IDMS.Migrations.Seed.SeedHelper.WithDbContext<TDbContext>(IIocResolver iocResolver, Action<TDbContext> contextAction) in SeedHelper.cs + 42. contextAction(context);

Infogroup.IDMS.Migrations.Seed.SeedHelper.SeedHostDb(IIocResolver iocResolver) in SeedHelper.cs + 18. WithDbContext<IDMSDbContext>(iocResolver, SeedHostDb);

Infogroup.IDMS.EntityFrameworkCore.IDMSEntityFrameworkCoreModule.PostInitialize() in IDMSEntityFrameworkCoreModule.cs + 58. SeedHelper.SeedHostDb(IocManager);

System.Collections.Generic.List.ForEach(Action<T> action)

Abp.AbpBootstrapper.Initialize() in AbpBootstrapper.cs

Abp.AspNetCore.AbpApplicationBuilderExtensions.UseAbp(IApplicationBuilder app, Action<AbpApplicationBuilderOptions> optionsAction) in AbpApplicationBuilderExtensions.cs

Infogroup.IDMS.Web.Startup.Startup.Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) in Startup.cs + 149. app.UseAbp(options =>

System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

Microsoft.AspNetCore.Hosting.ConventionBasedStartup.Configure(IApplicationBuilder app)

Microsoft.AspNetCore.ApplicationInsights.HostingStartup.ApplicationInsightsLoggerStartupFilter+<>c__DisplayClass0_1.<Configure>b__0(IApplicationBuilder builder)

Microsoft.ApplicationInsights.AspNetCore.ApplicationInsightsStartupFilter+<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder app)

Microsoft.AspNetCore.Server.IISIntegration.IISSetupFilter+<>c__DisplayClass3_0.<Configure>b__0(IApplicationBuilder app)

Microsoft.AspNetCore.Hosting.Internal.AutoRequestServicesStartupFilter+<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder builder)

Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()

Show raw exception details

System.Data.SqlClient.SqlException (0x80131904): Invalid object name 'AbpEditions'. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData() at System.Data.SqlClient.SqlDataReader.get_MetaData() at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, TaskCompletionSource1 completion, Int32 timeout, Task& task, Boolean asyncWrite, String method) at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior) at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) at System.Data.Common.DbCommand.ExecuteReader() at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.Execute(IRelationalConnection connection, DbCommandMethod executeMethod, IReadOnlyDictionary2 parameterValues) at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.ExecuteReader(IRelationalConnection connection, IReadOnlyDictionary2 parameterValues) at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable1.Enumerator.BufferlessMoveNext(Boolean buffer) at Microsoft.EntityFrameworkCore.Storage.Internal.SqlServerExecutionStrategy.Execute[TState,TResult](TState state, Func3 operation, Func3 verifySucceeded) at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable1.Enumerator.MoveNext() at System.Linq.Enumerable.TryGetFirst[TSource](IEnumerable1 source, Boolean& found) at lambda_method(Closure , QueryContext ) at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass17_11.<CompileQueryCore>b__0(QueryContext qc) at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.Execute[TResult](Expression query) at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryProvider.Execute[TResult](Expression expression) at System.Linq.Queryable.FirstOrDefault[TSource](IQueryable1 source, Expression1 predicate) at Infogroup.IDMS.Migrations.Seed.Host.DefaultEditionCreator.CreateEditions() in D:\Development\IDMS_vNext\IDMS\src\Infogroup.IDMS.EntityFrameworkCore\Migrations\Seed\Host\DefaultEditionCreator.cs:line 26 at Infogroup.IDMS.Migrations.Seed.Host.DefaultEditionCreator.Create() in D:\Development\IDMS_vNext\IDMS\src\Infogroup.IDMS.EntityFrameworkCore\Migrations\Seed\Host\DefaultEditionCreator.cs:line 21 at Infogroup.IDMS.Migrations.Seed.Host.InitialHostDbBuilder.Create() in D:\Development\IDMS_vNext\IDMS\src\Infogroup.IDMS.EntityFrameworkCore\Migrations\Seed\Host\InitialHostDbBuilder.cs:line 16 at Infogroup.IDMS.Migrations.Seed.SeedHelper.SeedHostDb(IDMSDbContext context) in D:\Development\IDMS_vNext\IDMS\src\Infogroup.IDMS.EntityFrameworkCore\Migrations\Seed\SeedHelper.cs:line 26 at Infogroup.IDMS.Migrations.Seed.SeedHelper.WithDbContext[TDbContext](IIocResolver iocResolver, Action1 contextAction) in D:\Development\IDMS_vNext\IDMS\src\Infogroup.IDMS.EntityFrameworkCore\Migrations\Seed\SeedHelper.cs:line 42 at Infogroup.IDMS.Migrations.Seed.SeedHelper.SeedHostDb(IIocResolver iocResolver) in D:\Development\IDMS_vNext\IDMS\src\Infogroup.IDMS.EntityFrameworkCore\Migrations\Seed\SeedHelper.cs:line 18 at Infogroup.IDMS.EntityFrameworkCore.IDMSEntityFrameworkCoreModule.PostInitialize() in D:\Development\IDMS_vNext\IDMS\src\Infogroup.IDMS.EntityFrameworkCore\EntityFrameworkCore\IDMSEntityFrameworkCoreModule.cs:line 58 at System.Collections.Generic.List1.ForEach(Action1 action) at Abp.AbpBootstrapper.Initialize() in D:\Github\aspnetboilerplate\src\Abp\AbpBootstrapper.cs:line 160 at Abp.AspNetCore.AbpApplicationBuilderExtensions.UseAbp(IApplicationBuilder app, Action`1 optionsAction) in D:\Github\aspnetboilerplate\src\Abp.AspNetCore\AspNetCore\AbpApplicationBuilderExtensions.cs:line 37 at Infogroup.IDMS.Web.Startup.Startup.Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) in D:\Development\IDMS_vNext\IDMS\src\Infogroup.IDMS.Web.Host\Startup\Startup.cs:line 149 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.Configure(IApplicationBuilder app) at Microsoft.AspNetCore.ApplicationInsights.HostingStartup.ApplicationInsightsLoggerStartupFilter.<>c__DisplayClass0_1.

**If, am not using the named instance of DB, the code works as desired and am able to connect with the DB.

"Default": "Server=SUMITSH-W10; Database=Dw_Admin_AspNetZero_Schema; Trusted_Connection=True;"

Not sure, if defining the connection string for the named instance correctly.**


3 Answer(s)
  • User Avatar
    0
    alper created
    Support Team

    hi,

    Your connection string is invalid! To connect to a named instance of SQL Server, use the server name\instance name syntax. See the related docs on Microsoft

    Data Source=MySqlServer\MSSQL1;"
    

    [X WRONG]

    "Default": "Server=SUMITSH-W10\\SQL2016; Database=IDMS_vNext_AspNetZero; Trusted_Connection=True;"
    

    [✓ CORRECT]

    "Default": "Server=SUMITSH-W10\SQL2016; Database=IDMS_vNext_AspNetZero; Trusted_Connection=True;"
    
  • User Avatar
    0
    sumitshah created

    Hi Alper,

    Thank you very much for the response.

    Have already tried your suggestion with no success.

  • User Avatar
    0
    ismcagdas created
    Support Team

    @sumitshah, havae you runned migrations before running your application ?