Using MVC 4 SimpleMembership with an existing database-first EF model

前端 未结 2 501
青春惊慌失措
青春惊慌失措 2020-12-08 05:48

I am trying to use SimpleMembership in my MVC 4 for the first time and I already have an existing database and EF5 model created based on it! I searched a lot but I cant fin

2条回答
  •  时光取名叫无心
    2020-12-08 06:17

    In your web.config in the appSettings tag, add the line

    
    

    SimpleMembership is built in so from here you simply need to write

    [InitializeSimpleMembership]
    

    above your public class AccountController: Controller

    When you want to force a user to log in for a certain page you write in the pages controller

    [Authorize]
    

    That tables will be automatically generated in your database. If you want to add more fields to these tables you will need to simply google it.

    Here's a link for more information http://weblogs.asp.net/jgalloway/archive/2012/08/29/simplemembership-membership-providers-universal-providers-and-the-new-asp-net-4-5-web-forms-and-asp-net-mvc-4-templates.aspx

提交回复
热议问题