I am creating an ASP.NET Web Application in mvc5 and i made a model class with a controller. My application is running but when i want to access my moviescontroller in url l
My LocalDB was deleted. I recreate it and my project now is running successfully. Thank you all to support me.
please use the correct connection string as provided in the tutorial:
<add name="MovieDBContext"
connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\Movies.mdf;Integrated Security=True"
providerName="System.Data.SqlClient"
/>
It is likely a problem with your authentication with the user sa
.
I have just installed VS 2013 on my DevVM (Server 2008R2) I created an Asp.Net MVC 5 project and used nuget to add Entity Framework to the project. After this I created the models and added the connectionstring to the web.config Then I clicked controlles -> add -> scaffold, choose the model data context and name, hit add and then run the project. Works like a charm. All CRUD functionality is working.
> Here EmployeeDetail is a table name and Employee is a model name. And
> ID,Branch,Salary and UID is a table field
public ActionResult Index()
{
List<EmployeeDetail> employees = context.EmployeeDetails.ToList();
List<Employee> emp = new List<Employee>();
foreach(EmployeeDetail item in employees)
{
emp.Add(new Employee
{
ID=Convert.ToInt32(item.ID),
Branch=item.Branch,`enter code here`
Salary=Conve`enter code here`rt.ToInt32(item.Salary),
UID = Convert.ToInt32(item.ID),
});
}
return View(emp);
}
> view page code
<div style="font-family:Arial">
<h2>Index</h2>
<ul>
@foreach (var emp in Model)
{
<li>
@Html.ActionLink(emp.Branch, "Details", new { id = emp.ID });
</li>
}
</ul>
</div>
I believe this is caused by 2 connection strings...had the same problem and getting rid of one helped.
Take care that you may also have some user.config files that have strayed into the path of being picked up by your application
C:\Users\USERNAME\AppData\Local\PROJECTNAME_vs_Url_a2dblg5lbsfkc1adurpcald1inggdlg1\
do not use "." to define the dbserver. use the full machine name