2014-02-13 34 views
1

跟蹤此博客與步驟,步驟http://www.windowsazure.com/en-us/documentation/articles/web-sites-dotnet-deploy-aspnet-mvc-app-membership-oauth-sql-database/#setupdevenv的Windows Azure - 遷移爲背景「ApplicationDbContext」

如果我從我的本地機器上運行的話,我看這是從Windows Azure的分貝來的數據,我可以添加和啓用更新或刪除...完美的工作正常,但問題是當我發佈我的應用程序到Windows Azure,我能夠看到我的頁面和所有的靜態頁面工作正常,但除了與數據庫交互的一個頁面。

這裏是我的web.config中的連接字符串:

<add name="DefaultConnection" connectionString="server=tcp:* insert server name*.database.windows.net,1433;Database=* insert database name *;User ID=*insert username *@* insert server name*;Password={*insert password here *};Trusted_Connection=False;Encrypt=True;Connection Timeout=30;" /> 

我得到這個消息時,我嘗試從http://XXXX.azurewebsites.net/Employee

錯誤信息訪問網頁:

Migrations is enabled for context 'ApplicationDbContext' but the database does not exist or contains no mapped tables. Use Migrations to create the database and its tables, for example by running the 'Update-Database' command from the Package Manager Console. 

回答

0

看來你數據庫不能自動創建。解決這個問題的最快方法是遵循錯誤消息中的建議。打開您的程序包管理器控制檯,其中包含連接字符串和Configuration.cs(您的遷移)的項目被選作啓動項目並運行更新數據庫。如果您在遷移過程中發生了某些變化,則可能必須將某些參數傳遞給此命令。