私は、とにかくAsp.NETアイデンティティを使用すると思います。
public class ApplicationUser : IdentityUser
{
public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager)
{
// Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
// Add custom user claims here
return userIdentity;
}
// Your Extended Properties
public string FirstName{ get; set; }
public string LastName{ get; set; }
//...
}
あなたもGetUserId()
方法と同じように簡単にプロパティの値を取得するためにUser.Identity
するためのメソッドを作成することができます:あなたはあなたのApplicationUser
あなたが以下のようにそれらを追加することができますための複数のプロパティを設定しなければなりません。見てくださいthis。
これは正確にアイデンティティが設計したものです。拡張性。 'ApplicationUser'に余分なプロパティが必要な場合は、それらを追加してください。他のエンティティとまったく同じです。 Owinは一般的にIdentityや認証とは関係ありません。アイデンティティはちょうどOwinミドルウェアとして動作します。 –
okey。そして、私はテーブルを参照していないユーザーテーブル(と\t 逆に)ApplicationUserから独立して完全に独立している場合、私はデータを取得するためにNHibernateを使用する必要がありますか? – Xeddon
@XeddonあなたがIDとApplicationUserの下にあるものは、それ自身のDbContextで処理され、ApplicationUserに関係しない他のテーブルが自分のORMによって処理される場合、それらのテーブルにUserIdを持たせたい場合、 NHibernateでそれらを外部キーとしてApplicationUserテーブルにマップします。 – Valkyrie