System.Data.Entity.Core.ProviderIncompatible Exception in MVC 5

前端 未结 6 1100
粉色の甜心
粉色の甜心 2021-01-01 22:05

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

相关标签:
6条回答
  • 2021-01-01 22:44

    My LocalDB was deleted. I recreate it and my project now is running successfully. Thank you all to support me.

    0 讨论(0)
  • 2021-01-01 22:48

    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.

    //Update

    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.

    0 讨论(0)
  • 2021-01-01 22:48
    > 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>
    
    0 讨论(0)
  • 2021-01-01 22:51

    I believe this is caused by 2 connection strings...had the same problem and getting rid of one helped.

    0 讨论(0)
  • 2021-01-01 22:58

    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\

    0 讨论(0)
  • 2021-01-01 23:01

    do not use "." to define the dbserver. use the full machine name

    0 讨论(0)
提交回复
热议问题