RoleManager MVC5/EF6

203 Views Asked by At

I started a MVC5 project with Individual User Accounts, I ran the initial migrations to get the database in place for users, roles et cetera.

I wrote a RolesController in an Admin Area, but from there, I am stuck. The first error was telling me to use roleManager, and include it in web.config. Alright, I did that according to an example I found on StackOverflow based on WebMatrix.WebData, but it didn't feel right, because it's a deprecated package on NuGet and integrated in Microsoft.AspNet.WebPages.WebData.

And there the trouble started, giving more and more errors, which I Googled and fixed by updating AspNet.WebPages.Data and other WebPages related packages.

Then, running the solution happened to give me more and more trouble, because eventually all solutions happened to be for MVC4/Membership instead of MVC5/Entity. I removed WebMatrix.WebData and kept WebPages at the new versions NuGet got me.

I then happened to stumble on a new word of advice found here. So I added that line to Web.Config, and everything ran happily ever after. Until I wanted to add a role, saving it took ages, resulting in this error: Unable to connect to SQL Server database. (System.Web.HttpException).

My ConnectionString never changed in Web.Config, so I am lost at what to do now. I hope someone can help me out. This is the connectionString: connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\aspnet-ImpHer-20141111023559.mdf;Initial Catalog=aspnet-ImpHer-20141111023559;Integrated Security=True"

0

There are 0 best solutions below