简体   繁体   中英

Can't connect to SQL Server at Appharbor

I have created a simple ASP.NET MVC 5 application.

I'm trying to connect to the remote sql server provided by Appharbor - https://appharbor.com/addons/sqlserver

So, visual part which does not use SQL requests works quite fine. SQL requests throw errors like

An error occurred while processing your request

I can't understand how to connect to the database.

I guess you deploy your code from github to apphb directly. Then you have to config the sequencer on the apphb page. In the plugin overview you can go to the configuration page for your sql server. there create a entry with the same name as your connection string. in your case "DefaultConnection".

the way is:

  1. click on your app on apphb
  2. under "Installed add-ons" click on SQL Server
  3. click "Go to SQL Server"
  4. click button "Edit database configuration"
  5. Add alias "DefaultConnection" (name from your connection string)
  6. click "save"
  7. deploy your webpage again

Next time you push to github and the hook triggers a build to apphb the server will automatically replace your local connection string with the apphb connection string.

if you want to prepare your apphb database you have to let run the 'update-database' call from your visual studio. copy past the connection string from apphb to your web.config and run 'update-database' in your console to prepare the external DB with our schema. But before you should add data within the Seed methode

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