1. 程式人生 > >Identity server4改用MySQL存儲數據

Identity server4改用MySQL存儲數據

startup 分享 技術分享 pom .com 技術 數據庫連接 ram 添加

進入github下載Identity server4與ef core集成的源碼,源碼地址為:https://github.com/IdentityServer/IdentityServer4.EntityFramework

打開該項目,設置Host項目為啟動項目,添加Pomelo.EntityFrameworkCore.MySql及Pomelo.EntityFrameworkCore.MySql.Design兩個nuget引用。

技術分享

修改StartUp中的數據庫連接信息:

技術分享

檢查Migrations文件夾中主鍵的Annotation信息,原來的例子是使用SQL SERVER,改用MySQL主鍵的自增需要改為如下代碼:

技術分享

運行項目,發現數據庫已成功生成,頁面也能正常訪問。

Identity server4改用MySQL存儲數據