簡體   English   中英

如何在Azure門戶中覆蓋Azure Sql連接

[英]How to override Azure Sql connection in Azure portal

我試圖重寫connectionstring與此相關的Azure的門戶網站:

Server=tcp:server.database.windows.net,1433;Database=mydatabase;User ID=username@server;Password=xxxxxx;Trusted_Connection=False;Encrypt=True;Connection Timeout=30;

它給了我一個錯誤Keyword not supported: 'server' ,當我嘗試它時:

metadata=res://*/DataAccess.MyDataBase.csdl|res://*/DataAccess.MyDataBase.ssdl|res://*/DataAccess.MyDataBase.msl;provider=System.Data.SqlClient;provider connection string="data source=tcp:server.database.windows.net,1433;initial catalog=MyDataBase;persist security info=True;user id=username@server;password=xxxxxx;MultipleActiveResultSets=True;App=EntityFramework""

它給出了"Keyword not supported: 'metadata'. !!

那么我應該寫的確切的connectionstring字符串是什么?

我還嘗試了屏幕截圖中提供的所有連接字符串類型。 在此輸入圖像描述

好的,我找到了一個與我的問題相關的答案 ,但我也找到了一些東西

首先連接字符串應該是這樣的

metadata=res://*/DataAccess.MyDataBase.csdl|res://*/DataAccess.MyDataBase.ssdl|res://*/DataAccess.MyDataBase.msl;provider=System.Data.SqlClient;provider connection string="Server=tcp:server.database.windows.net,1433;Database=MyDataBase;User ID=username@server;Password=xxxxxx;Trusted_Connection=False;Encrypt=True;Connection Timeout=30;"

並注意引用應該是"" ,同樣尼克說它應該是Custom

第一個連接字符串('Server = ..')用於直接連接到數據庫,而不通過Entity Framework。
第二個連接字符串('metadata = ..')是一個Entity Framework連接字符串。 如果您使用EF,則應將Azure管理門戶中的連接字符串標記為“自定義”而不是“SQL數據庫”

在控制面板中,數據庫面板上有一個“顯示數據庫連接字符串”的位置,它為您提供ADO.Net,PHP,Java和ODBC數據庫的完整連接字符串。 這些可以作為一個起點,我從中添加了MARS支持和一個不同的用戶/密碼。

這是我的連接字符串,以幫助您。 我們使用這個在Azure WebApps控制面板中覆蓋。

Server=tcp:[AZURE_DB_NAME].database.windows.net,1433;Database=[DATABASE_NAME];User ID=[USER_ID];Password=[PASSWORD];Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;MultipleActiveResultSets=True

至於Drop Down,我們將它設置為SQL數據庫。

想到一件事。 您是否嘗試在VS Debug模式下使用連接字符串來查看會發生什么? 您只需將AzureDB配置為允許從IP進行遠程連接即可。 它可以為您提供一些見解,即您的連接是正確的,但其他東西是失敗的。

我嘗試了Mohamed Farrag的解決方案但是遇到了這個錯誤:

System.ArgumentException:不支持關鍵字:'.ssdl | res://*/dataaccess.MyDataBase.msl; provider'。

刪除DataAccess. 從我的連接字符串工作:

metadata=res://*/MyDataBase.csdl|res://*/MyDataBase.ssdl|res://*/MyDataBase.msl;provider=System.Data.SqlClient;provider connection string="Server=tcp:server.database.windows.net,1433;Database=MyDataBase;User ID=username@server;Password=xxxxxx;Trusted_Connection=False;Encrypt=True;Connection Timeout=30;"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM