1

I am trying to get the role of currently logged in user. Here is my code

string[] rolesuserbelongto = Roles.GetRolesForUser();

  <roleManager enabled="true" /> 

in web.config

The error I am getting is the following

An error occurred during the execution of the SQL file 'InstallCommon.sql'. The SQL error number is 5170 and the SqlException message is: Cannot create file 'C:******\ASPNETDB_TMP.MDF' because it already exists. Change the file path or the file name, and retry the operation. CREATE DATABASE failed. Some file names listed could not be created. Check related errors. Creating the ASPNETDB_a59f73a02db543de9eafe5c626a03ff0 database...

How can this be resolved? Please I am new to c# mvc .

8
  • Looks much more like a db error as Code First tries to create a user db. Is this the first time your app contacts the database?
    – ste-fu
    Dec 19, 2016 at 9:04
  • Are you using RoleProvider for Getting Roles? Dec 19, 2016 at 9:08
  • 1
    Your ASPNETDB_TMP.MDF DB file already exists, hence something wrong happened on web.config file (post complete content to help find out your issue). If the DB is auto-generated, you need to change current behavior when checking existing DB. Dec 19, 2016 at 9:19
  • dotnetcurry.com/aspnet-mvc/1102/aspnet-mvc-role-based-security this link is what i followed to create roles and assign roles to user.
    – Philomath
    Dec 19, 2016 at 11:20
  • @ste-fu no i also have options to create role and assign role to user.
    – Philomath
    Dec 19, 2016 at 21:06

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.