私のASP.NETプロジェクトでは、ユーザーの現在の役割をIDで取得しようとしています。ここでは、コントローラのための私のコードは次のとおりです。私はそれを実行しようとするとASP.NET MVC 5-特定のユーザーのロールを取得する
public ActionResult ChangeRole(string id)
{
var user = _context.Users.Single(u => u.Id == id);
var roles = new RoleManagerViewModel()
{
RoleNames = Roles.GetRolesForUser(user.Id)
};
return View(roles);
}
しかし私はこのエラーを取得:
The Role Manager feature has not been enabled.
私はroleManager enabled="true"
を追加することによって、その問題を解決できることを読みました。
私はweb.config
ファイルにあることを追加した後、私はこのエラーを取得するのに:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
私のコンピュータ上のローカルデータベースにアクセスしているだけなので、なぜ私はエラーが発生しているのか試してみるのは混乱していると思います。 – ecain
データソースにdb localを使用しようとしましたか? – JDavila