私はmvc.netを使ってWebアプリケーションを開発するためにまずコードを使用しています。 私は私が私の最初のコントローラエラー:mvc.netコードで何も変更していないのに、DataContextが変更されました。
これとは別に UserId = User.Identity.GetUserId(),
NewUserId = Genrate.GenrateUserId(),
NewUserIdWithString = "Unspecified"
にこのフィールドを使用し、この
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;
}
public string ScreenName { get; set; }
public string UserType { get; set; }
}
ようIdentityUserに二つのフィールドを追加して、すべてのアプリケーションが正常に動作しますが、私はこの事を追加した後に知りません何も動作せず、datacontextが変更されている、別の問題が存在する可能性があります/ sです。
私はマイグレーションを更新しましたが、それがあれば動作しません。私は移行フォルダを削除しません。移行フォルダを削除すると、アプリケーションが動作します。 – Nil
あなたはデータベースを更新するのを忘れませんでしたか?また、データベース内のユーザーテーブルを表示する場合は、2つの追加フィールドが表示されますか? migrationsフォルダは通常どんな問題も引き起こしてはいけません...新しいエラーが出ていますか?おそらくデータベースを更新するときに "許可なし"のように? – counterflux
さて、今度は問題はないと思います。必要なときにいくつかのフィールドを更新してみて、もう一度やり直してみてください、ありがとうございます! – Nil