Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET MVC database can not access

I download a open source MVC project and I can not run it. The author mentioned in the memo that I should change the database owner to myself. But I don't know how to do it. And I can not see the database in the SQL server Object explorer.

An exception of type 'System.Data.Entity.Core.ProviderIncompatibleException' occurred in EntityFramework.dll but was not handled in user code

Additional information: An error occurred accessing the database. This usually means that the connection to the database failed. Check that the connection string is correct and that the appropriate DbContext constructor is being used to specify it or find it in the application's config file.

See http://go.microsoft.com/fwlink/?LinkId=386386 for information on DbContext and connections. See the inner exception for details of the failure.

The error pointed here

public override TEntity ReadOne(ISpecification<TEntity> spec) {
    return this.set.Where(spec.IsSatisfied).FirstOrDefault();
}

web.config:

<connectionStrings>
    <add name="mvcForum.DataProvider.MainDB" connectionString="Data Source=SERVERNAMEorSERVERNAME\INSTANCE;Initial Catalog=DBNAME;User ID=USER;password=PASSWORD"/>
    <!--add name="mvcForum.DataProvider.MainDB" connectionString="Data Source=.\SQL2008r2Express;Initial Catalog=mvcforum;User ID=test;password=test;" providerName="System.Data.SqlClient" />-->
    <!--<add name="User.MongoDB" connectionString="mongodb://localhost/mvcforum" />-->
</connectionStrings>
like image 547
user2840454 Avatar asked Apr 19 '14 14:04

user2840454


1 Answers

You need to change the connection string, the simplest way is to open server explorer in visual studio then add new connection, after creating connection to your database, copy and paste connectionstring from properties window

like image 186
Reza Avatar answered Nov 01 '22 01:11

Reza