0

…少なくとも、私はそれが起こっていると思います。

MVC Web サイトで UserProfile テーブルを使用して、userID と userName 以外のものを保持しようとしています。

申し訳ありませんが、私はひどい初心者であり、これがサンプル コードの貧弱なハックであることはわかっていますが、AccountController にあるものは次のとおりです。

    Public Function Register(ByVal model As RegisterModel) As ActionResult

        If ModelState.IsValid Then
        Using db As New UsersContext()
            ' Attempt to register the user
            Try
                WebSecurity.CreateUserAndAccount(model.UserName, model.Password)
                WebSecurity.Login(model.UserName, model.Password)

                Dim id As Integer = WebSecurity.GetUserId(User.Identity.Name)

                Dim userProfile As UserProfile = db.UserProfile.Find(id)
                If IsNothing(UserProfile) Then
                    Return HttpNotFound()
                End If


                db.Entry(UserProfile).State = EntityState.Modified
                db.SaveChanges()

                Return RedirectToAction("Index", "Home")
            Catch e As MembershipCreateUserException

                ModelState.AddModelError("", ErrorCodeToString(e.StatusCode))
            End Try
        End Using
    End If

dboを追加していることを除いて、機能しているようです。ハリファックスの代わりにテーブル名の前に。私は自分のスキーマに持っています。そこで何を使用するかをどのように伝えますか?私がdboを入れた場合。表、コードは実行されますが、プロファイル情報が間違った場所に置かれます。

4

1 に答える 1