Click here to Skip to main content
15,887,485 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Controller Class-
public class HomeController : Controller
    {
        OdeToFood2Db _db = new OdeToFood2Db();
        public ActionResult Index()
        {
            var model = _db.Restaurants.ToList();
            return View(model);
        }


Entity Frame work DBCOntext class-
public class OdeToFood2Db:DbContext
    {
        public DbSet<Restaurant> Restaurants { get; set; }
        public DbSet<RestaurantReview> Reviews { get; set; }
    }


Web Config-
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-OdeToFood2-20170119174541;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-OdeToFood2-20170119174541.mdf" providerName="System.Data.SqlClient" />


On execution of the Controller class- the exception is coming-
ProviderIncompatibleException was unhandled by user code

An error occurred while getting provider information from the database. This can be caused by Entity Framework using an incorrect connection string. Check the inner exceptions for details and ensure that the connection string is correct.


What I have tried:

I am having the exception and not able to resolve, please help
Posted
Updated 8-Mar-17 2:01am

Microsoft's description of the exception: ProviderIncompatibleException Class (System.Data)[^] indicates a few possible scenarios and googling (see below) strongly suggests that it is most likely your connection string.

Google search: provider incompatible exception[^]
 
Share this answer
 
My Query String is-
<add name="DefaultConnection" connectionString="Data Source=(Localdb)\v11.0;Initial Catalog=aspnet-OdeToFood-20161225201813;Integrated Security=True" providerName="System.Data.SqlClient" />


And what i got from database explorer->DataCOnnection->Default Connection is -
Connection String->
Data Source=(Localdb)\v11.0;Initial Catalog=aspnet-OdeToFood-20161225201813;Integrated Security=True

provider-
.NET Framework Data Provider for SQL Server

Seems its correct, still not working
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900