Dies ist eine Frage, die Azure mit SQL Server und einer Webanwendung betrifft.Fehler in Azure, wenn eine Webanwendung zum ersten Mal nach dem Erstellen einer Tabelle in eine SQL Server-Datenbank einzufügen versucht
Alles funktioniert gut lokal. Das Problem besteht nur in Azure.
Ich habe einen SQL Server mit einer Datenbank eingerichtet und eine Web App veröffentlicht. Sie verwenden dieselbe Region.
Alles hat Standardeinstellungen, außer dass meine lokale IP Verbindung mit dem Datenbankserver herstellen kann.
Ich kann eine Verbindung zu Azure SQL Server von SQL Server Management Studio und ich sehe meine Datenbank dort.
Das erste, was ich in der Web-App mache, ist der Versuch, einen neuen Benutzer zu registrieren. Die beteiligten Technologien sind ASP.NET MVC5, ASP.NET Identity und Entity Framework mit Migrationsskripten. Normales MS-Zeug.
Ich habe die ApplicationDbContext(DefaultConnection)
im Publish/Settings/Databases-Dialog eingestellt und aktiviert "Code First Migrations ausführen".
Das Migrationsskript läuft einwandfrei. Alle Tabellen wurden erstellt und werden in SQL Server Management Studio angezeigt.
Wenn die Webanwendung jedoch versucht, der Tabelle User
einen neuen Benutzer hinzuzufügen, wird der folgende Fehler angezeigt.
So .. Die Web-App hat offensichtlich eine Verbindung und Zugriffsrechte auf die Datenbank, seit alle Tabellen erstellt wurden. Irgendeine Idee, was ich vermisse?
Danke für jede Hilfe und Eingabe!
Update:
In der web.config ich eine neue Connection gefunden: DefaultConnection_DatabasePublish
mit der richtigen Konfiguration.
Irgendwie war das Original DefaultConnection
geändert zu Data Source=localhost;Initial Catalog={catalog};Integrated Security=True
nachdem es veröffentlicht wurde.
Das Ändern der DefaultConnection auf das gleiche wie DefaultConnection_DatabasePublish löste das Problem.
Ich hatte dieses Verhalten nicht zuvor bei der Veröffentlichung. Ich habe die Option "Erste Code-Migrationen ausführen" noch nicht aktiviert. Kann jemand bestätigen, ob das Verhalten damit zusammenhängt?
Server Error in '/' Application.
The system cannot find the file specified
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ComponentModel.Win32Exception: The system cannot find the file specified
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[Win32Exception (0x80004005): The system cannot find the file specified]
[SqlException (0x80131904): 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)]
System.Data.SqlClient.SqlInternalConnectionTds.. ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, String accessToken, Boolean applyTransientFaultHandling) +821
System.Data.SqlClient.SqlConnectionFactory.CreateConnection (DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) +332
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection (DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) +38
System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) +699
System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) +89
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) +426
System.Data.ProviderBase.DbConnectionPool.WaitForPendingOpen() +343
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +99
System.Runtime.CompilerServices.TaskAwaiter. HandleNonSuccessAndDebuggerNotification(Task task) +58
System.Data.Entity.SqlServer.<b__3>d__6.MoveNext() +226
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +99
System.Runtime.CompilerServices.TaskAwaiter. HandleNonSuccessAndDebuggerNotification(Task task) +58
System.Data.Entity.SqlServer.d__9`1.MoveNext() +354
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +99
System.Runtime.CompilerServices.TaskAwaiter. HandleNonSuccessAndDebuggerNotification(Task task) +58
System.Data.Entity.Core.EntityClient.d__8.MoveNext() +594