Я поместил строку подключения в пользовательский файл конфигурации под названием «Connections.config».И я добавил запись в App.Config как
<connectionStrings configSource="Connections.config">
</connectionStrings>
В Connections.config у меня есть строка подключения как:
<connectionStrings>
<add name="ApplicationDbContextConnection" connectionString="data source=;initial catalog=;user id=sa;password=;MultipleActiveResultSets=True;App=EntityFramework" providerName="System.Data.SqlClient"/>
</connectionStrings>
Когда я запускаю Add-migrationЯ получаю сообщение об ошибке: «В файле конфигурации приложения не найдена строка подключения с именем« ApplicationDbContextConnection ».»
System.InvalidOperationException: No connection string named 'ApplicationDbContextConnection' could be found in the application config file.
at System.Data.Entity.Internal.LazyInternalConnection.Initialize()
at System.Data.Entity.Internal.LazyInternalConnection.get_Connection()
at System.Data.Entity.Internal.LazyInternalContext.get_Connection()
at System.Data.Entity.Infrastructure.DbContextInfo..ctor(Type contextType, DbProviderInfo modelProviderInfo, AppConfig config, DbConnectionInfo connectionInfo, Func`1 resolver)
at System.Data.Entity.Migrations.DbMigrator..ctor(DbMigrationsConfiguration configuration, DbContext usersContext, DatabaseExistenceState existenceState, Boolean calledByCreateDatabase)
at System.Data.Entity.Migrations.DbMigrator..ctor(DbMigrationsConfiguration configuration)
at System.Data.Entity.Migrations.Design.MigrationScaffolder..ctor(DbMigrationsConfiguration migrationsConfiguration)
at System.Data.Entity.Migrations.Design.ToolingFacade.ScaffoldRunner.RunCore()
at System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.Run()
No connection string named 'ApplicationDbContextConnection' could be found in the application config file.
Кроме этого проекта у меня есть несколько проектов в решении, использующем другой DbContext.
Есть ли способ преодолеть это, используя строку подключения в пользовательском файле "Connections.config".