I have an MVC application using the .Net framework that uses Authentication with individual user accounts.
Everything works great.
I am able to register new users and login with them. CRUD operations work on all of my models.
Then I wanted to add some role based authentication.
I have 2 roles, Visitor and Admin. Users will be automatically assigned the visitor role when they register. I have written a method for the admin users to search all users for an email and assign that person to Admin role.
Then I added this to my _Layout.cshtml file
if (User.IsInRole("Admin"))
{
<li>@Html.ActionLink("Admin Menu", "Index", "Main", new { area = "Admin"},null)</li>
}
I build and run.
At which time it threw an error pointing to that line, saying it could not find the Sql Server Express database. I don't use Sql Server Express. Why isn't it using the connection string listed in my Web.config file?
Here is the relevant part of my Web.config file
<connectionStrings>
<add name="DefaultConnection"
connectionString="Data Source=DESKTOP-6HOPM3U;Initial Catalog=MoveMyTub;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"
providerName="System.Data.SqlClient" />
</connectionStrings>
Is there something in Identity.Config that I need to find and change so that it uses the default connection string and doesn't look for some non-existant Sql Server Express version?