MVC 5 IsInRole Usage on Razor Views: Cannot connect to Database

后端 未结 3 881
长情又很酷
长情又很酷 2021-02-07 18:38

I\'m having issues using the new identity system in MVC 5, my goal is to make use of the User.IsinRole(\"RoleName\") on Views. For example:

@if(User.IsInRole(\"A         


        
3条回答
  •  离开以前
    2021-02-07 18:51

    Create database on start up of the application. Add the following in the Global.ascx with your dbcontext.

    using (FooContext db = new FooContext()) 
            {
                db.Database.CreateIfNotExists();
            }
    

提交回复
热议问题