เปลี่ยนจาก Sqlite มาใช้ SqlServer

appsettings.json

Continue reading

scaffolder เพื่อแสดงไฟล์ Register , Login , Logout

Configure Identity services

ติดตั้ง ASP.NET Core scaffolder

[code]
> dotnet tool install -g dotnet-aspnet-codegenerator
[/code]

เข้าไปใน project directory แล้วทำการ add package Microsoft.VisualStudio.Web.CodeGeneration.Design

[code]
> dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design
> dotnet restore
[/code]

สั่ง scaffolder

ข้อควรระวังคือ -dc webAppIdentity.Data.ApplicationDbContext ต้องเป็นชื่อโปรเจ็กส์ที่ถูกต้องทั้งตัวพิมพ์เล็กพิมพ์ใหญ่
ไม่งั้นตอนรันจะ error ฟ้องว่ามี 2 schema

แสดงไฟล์ที่เกี่ยวข้องกับ Account.Register , Account.Login , Account.Logout ออกมา

[code]
> dotnet aspnet-codegenerator identity -dc webAppIdentity.Data.ApplicationDbContext –files "Account.Register;Account.Login;Account.Logout"
[/code]

หรือ scaffolder ไฟล์ทั้งหมดออกมาเลย (เยอะมาก)

[code]
> dotnet aspnet-codegenerator identity -dc webAppIdentity.Data.ApplicationDbContext
[/code]

แต่อย่าลืมกำหนดชื่อโปรเจ็กส์ด้วยนะ ในที่นี้ใช้ webAppIdentity

Continue reading

สร้างโปรเจ็กส์แบบ webapp มี Authen แบบ Individual

สร้างโปรเจ็กส์แบบ webapp ชื่อโปรเจ็กส์ webAppIdentity

[code]
> dotnet new webapp –auth Individual -o webAppIdentity
> cd webAppIdentity
[/code]

Program.cs

Continue reading