Jetbrains 系列的 IDE 都可以在開發的時候都可以擁有 SQL Intellisense,這將替我們解省掉打字所造成的除錯時間,Database Connection Windows 提供更方便的介面讓我們觀察資料庫的狀態,可以 CRUD(別直接用線上資料庫)、觀察執行計畫。
開發環境
- Rider 2021.1.1
- Windows 10
Database Connection
這個跟 VS IDE 的 SSDT 很類似,可以讓我們在開發工具直接控制資料庫,不同的資料庫連接除了 Driver / Provider 不同,操作步驟都是大同小異。
Ctrl+Alt+3 → New Data Source → SQLite Driver → DB Flie

接下來就選 SQLite 的檔案和 Driver

Driver 安裝路徑為 %userprofile%\AppData\Roaming\JetBrains\Rider2021.1\jdbc-drivers
完成之後就能夠,在開發 IDE 裡面直接控制資料庫了

參考:
Database connection | JetBrains Rider
Execute SQL Raw
Execute / Run Query in Console
- 鍵盤焦點停在 Sql Raw 內 → enter + alt → 輸入 run,選擇 Run query in console,或是按下 ctrl + enter

第一次使用會跳出 New Session 快選視窗,按下 enter

這時會跳出另一個 Service Window,裡面會記錄你的查詢以及結果

Database 變成連線狀態

查詢過的結果可以
- 匯出檔案
- 觀察執行計畫

Execute to File
支援多種匯出格式

Execute Plan
觀察有沒有吃到索引

SQL Dialects
Ctrl+Alt+S → 搜尋 dialects → SQL Dialects
SQL Dialects 的設定可分為 Global、Project、File 層級,這是在跟 IDE 講那些需要分析 SQL,完成之後編寫 SQL Raw 的時候就會有 Instellisense、Reformat Code 的功能了
下圖我設定 Project 層級

產生 sql dialects,鍵盤焦點停在 SQL Raw → alt + enter,跳出 Change dialects

Instellisense
在 C# 編寫 SQL Raw 也可以有 Instellisense

Analytic SQL Raw
解析語法,幫你標出有問題的地方,不過這不影響 C# 編譯

參考:
SQL Dialects | JetBrains Rider
若有謬誤,煩請告知,新手發帖請多包涵
Microsoft MVP Award 2010~2017 C# 第四季
Microsoft MVP Award 2018~2022 .NET