ASP.NET Core Bugs

整理自己所遇到的 Bugs:
  • 如果加了 services.AddIdentity, 但是 register 跟 login url 會變成這樣的話, 要記得在 AddIdentity 裡面加上 AddDefaultUI()

  • Severity Code Description Project File Line Suppression State Error CS1061 'AuthenticationBuilder' does not contain a definition for 'AddGoogle' and no accessible extension method 'AddGoogle' accepting a first argument of type 'AuthenticationBuilder' could be found (are you missing a using directive or an assembly reference?)
去 Nuget Package Manager install Microsoft.AspNetCore.Authentication.Google

  • Tag Helper 要跟 Controller 的 parameter 的字要一模一樣

Alter SQL Server 裡面的 Table 之後, 必須要做 Migration (如果使用 EF)
Migration problems :
  • 要 Migration 之前, 一定要先 Enable-Migration
  • 再來才可以 Add-Migration
    • 如果 Add-Migration 出現 build-failed 的情況, 表示 code 裡面有 bugs, 要先 comment out
  • 如果有很多個 DBContext, 那麼就要指定一個 DBContext
  • 重複的 Migration Name 也是不合法的, 解決方法就是取不同名字就好

InvalidOperationException: Session has not been configured for this application or request.
要記得去 startup.cs register session.

留言