How to call update-database from the package manager console in Visual Studio vs SQL Azure?

I am using EF 6.1.3. I am trying to call update-database from the package manager console against SQL Azure. Everything works fine with local SQL Express 2012. I can successfully connect to the server with SQL Server Management Studio 2012/2014 and with Visual Studio Server Explorer with the same credentials. I already made an exception on the Azure SQL Firewall from the management portal, but I get an error:

Error number: 18456, State: 1, Class: 14 Login failed for user "xxxxxxx". The trace identifier "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" was assigned in this session. Provide this trace identifier for customer support when you need help.

The exception is:

System.Data.SqlClient.SqlException (0x80131904): Login failed for user "xxxxx". The trace identifier "xxxxxx" was assigned to this session. Provide this trace identifier for customer support when you need help. in System.Data.ProviderBase.DbConnectionPool.TryGetConnection (DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionConectionBetConnectionBename.DataConnectionBetone.DataConnectionBetone.DataConnectionBetone.DataConnectionOnions1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource1 was repeated, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal and connection) in System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal (DbConnection externalConnection, DbConnectionFactory connectionFactory, TaskCompletionSource 1 retry, DbConnectionOptions userOptions) at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource1 retry, DbConnectionOptions userOptions) in System.Data.SqlClient.SqlConnection.TryOpenInner (TaskCompletionSource 1 retry) at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource1 repeat) in System.Data.SqlClient.SqlConnection.Open () in System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.b__36 (DbConnection t, DbConnectionInterceptionContext c) in System.Data.Entity.Infrastructure.Interception.InternalDispatcher 1.Dispatch[TTarget,TInterceptionContext](TTarget target, Action2 operation, TInterceptionContext interceptionContext, Action3 executing, Action3 completed) in System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.Open (DbConnection connection, DbInterceptionContext interceptionContext) in System.Data.Entity.SqlServer.SqlProviderServices. <> c__DisplayClass33.b__32 () in System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy. <> c__DisplayClass1.b__0 () in System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute [TResult] (Func 1 operation) at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute(Action operation) at System.Data.Entity.SqlServer.SqlProviderServices.UsingConnection(DbConnection sqlConnection, Action1 act) in System.Data.Entity.SqlServer.SqlProviderServices.UsingMasterConnection (DbConnection sqlCectionConnectionConnConnection 1 act) at System.Data.Entity.SqlServer.SqlProviderServices.CreateDatabaseFromScript(NullablesqlConnection sqlConnection String createDatabaseScript) in System.Data.Entity.SqlServer.SqlProviderServices.DbCreateDatabase (connection DbConnection, Nullable1 commandTimeout, StoreItemCollection storeItemCollection) at System.Data.Entity.Core.Common.DbProviderServices.CreateDatabase(DbConnection connection, Nullable1 commandTimeout, StoreItemCollection storeItemCollection) in System.Data.Entity.Core.Objects.ObjectContext.CreateDatabase () in System.Data.Entity.Migrations.Utilities.DatabaseCreator.Create (DbConnection connection) in System.Data.Entity.Migrations.Db .EnsureDatabaseExists (Action mustSucceedToKeepDatabase) in System.Data.Entity.Migrations.Infrastructure.MigratorBase.EnsureDatabaseExists (Action mustSucceedToKeepDatabase) in System.Data.Entity.Migrations.DbMigrator.Update (String targetMigration) in System.DataEstructure. String.Migration. .MigratorBase.Update (String targetMigration) in System.Data.Entity.Migrations.Design.ToolingFacade.UpdateRunner.Run () in System.AppDomain.DoCallBack (CrossAppDomainDelegate callBackDelegate) in System.AppDomain.DoCeDateBackDackDlegDackDebDlegDackDlegDackBack () .Entity.Migrations.Design.ToolingFacade.Run (BaseRunner runner) in System.Data.Entity.Migrations.Design.ToolingFacade.Update (String targetMigration, Boolean force) in System.Data.Entity.Migrations.UpdateDatabaseCommand. <> c__DisplayClass2. <.ctor> b__0 () in System.Data.Entity.Migrations.MigrationsDomainCommand.Execute (action command) ClientConnectionId: xxxxx

:

--SourceMigration XXXXXX -TargetMigration -StartUpProjectName -ProjectName xxxxx.Migrations -ConfigurationTypeName "xxxxx.MigrationConfiguration" -ConnectionString " = TCP: xxxxxx.database.windows.net 1433; = XXXXXX; = xxxxxx; = xxxxxx; Trusted_Connection = False; = ; = 30; -ConnectionProviderName" System.Data.SqlClient" -Force

. - , ?

: "xxxxxxx". xxxx @serverName. ?

+4
1

- @ . Sql Azure @serverName. Azure EF :

-ConnectionString "connString @serverName"

"_ @serverName", " ", "_ @_".

Entity Framework " ", "_ @_" . , , @serverName, . EF . ( )

- . :

-ConnectionString 'connString "username @serverName"....'

, , @, EF .

+5

Source: https://habr.com/ru/post/1613310/


All Articles