简体   繁体   中英

The underlying provider failed on Open. MVC

I am developing an application which consists of service, data layer(which is class library) and mvc project. I am using EF 5. My connection string is the following:

add name="PicknickDBEntities" 
     connectionString="metadata=res://*/Model.csdl|res://*/Model.ssdl|res://*/Model.msl;
     provider=System.Data.SqlClient;
     provider connection string="
     data source=*******\SQLEXPRESS;
     initial catalog=PicknickDB;
     integrated security=True;
     User Instance=True;
     MultipleActiveResultSets=True;
     App=EntityFramework"
     " providerName="System.Data.EntityClient" />

I just copied this one from the service web.config but it is not working under the IIS. Any ideas?

PS(I know that this question appears at least a few times with good solutions but I wasn't unable to find the correct one for me.)

Try something along these lines.

     <add name="LeaveMSContext"
    connectionString="Data Source=*******\SQLEXPRESS; 
    Initial Catalog=NAMEOFYOURDATABASE; Integrated Security=True;
    AttachDbFilename=|DataDirectory|DATABASEFILE.mdf 
    MultipleActiveResultSets=True; "
    providerName="System.Data.SqlClient"/>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM