2014-12-27 34 views
0

我試圖託管我的ASP.NET MVC 5實體框架代碼第一個項目(該項目運行完美,我的機器上有本地數據庫連接字符串)在去爸爸。我一直在收到一些錯誤,直到現在我才能糾正它們。託管我的MVC 5實體框架代碼第一個項目!多個錯誤

現在,我得到這個錯誤:

CREATE DATABASE permission denied in database 'master'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: CREATE DATABASE permission denied in database 'master'.

我已經刪除了信任級別選項在我的web.config文件,因爲它是在的asp.net網絡參數創建與CAS信任級別問題去吧爸爸。我父親的CAS信任級別已滿。

我的連接字符串:

<add name="DefaultConnection" 
    connectionString="Data Source=ipadress;AttachDbFilename=|DataDirectory|\aspnet-aspProjetFinal-20141211061340.mdf;Initial Catalog=aspnet-aspProjetFinal-20141211061340;Integrated Security=false;User Id=myuser; Password=mypassword;" 
    providerName="System.Data.SqlClient" /> 
<add name="monModel" 
    connectionString="data source=ipadress;initial catalog=GestionClientsContext;Trusted_Connection=True;Integrated Security=false;MultipleActiveResultSets=True;App=EntityFramework;User Id=myuser; Password=mypassword;" 
    providerName="System.Data.SqlClient" />  

我已經嘗試了一些東西,比如,這樣的:

http://forums.asp.net/t/1742970.aspx?CREATE+DATABASE+permission+denied+in+database+master+

但我不知道我是否需要刪除一些線路在代碼頂部添加所述行後。

global.asax.cs文件:

public class MvcApplication : System.Web.HttpApplication 
{ 
    protected void Application_Start() 
    { 
     Database.SetInitializer<GestionClientsContext>(null); 
     Database.SetInitializer(new InitialisationGestionClients()); 
     GestionClientsContext testing = new GestionClientsContext(); 
     testing.Database.Initialize(true); 
     AreaRegistration.RegisterAllAreas(); 
     FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); 
     RouteConfig.RegisterRoutes(RouteTable.Routes); 
     BundleConfig.RegisterBundles(BundleTable.Bundles); 
     //throw new Exception(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString); 
    }  

我顯然需要一些指導,我已經花了很多的時間只是想在網上得到它!讓我知道你的想法 !謝謝 !

+0

你能向我們展示'InitialisationGestionClients()'初始化器嗎?你在使用「DropCreateDatabaseIfModelChanges」方案嗎?如果是這樣,那可能是原因,因爲GoDaddy不允許你從代碼中刪除或創建數據庫,只有控制面板。 – Dan 2014-12-28 03:54:06

+0

您的數據庫是否已經存在?,您是否在聯繫人中設置了連接字符串?或有管理員用戶訪問你的數據庫在SQL? – Aria 2014-12-28 18:34:04

+0

我的2個DB已經存在,一個連接到上下文,另一個連接登錄和角色。我自己在服務器上創建了它們。 – TopCheese 2014-12-29 18:34:56

回答

0

你問丹:

public class InitialisationGestionClients : System.Data.Entity.CreateDatabaseIfNotExists<GestionClientsContext> 
{ 
    protected override void Seed(GestionClientsContext context) 
    { 
     base.Seed(context); 
     var lesClients = new List<Clients> 
     { 
      new Clients{nom="Finch", prenom="Paul",dateInscription=DateTime.Parse("2014-01-10"),adresse="911 De la Commune", email="[email protected]", solde=0,commentaires="Juste un test"} 
     }; 
     lesClients.ForEach(s => context.Clients.Add(s)); 
     context.SaveChanges(); 

     var lesFacures = new List<Factures> 
     { 
      new Factures{motif="Programmes janvier 2014", montant=25,dateFacturation=DateTime.Parse("2014-01-10"),statusPaid=false, ClientsId=1} 
     }; 

     lesFacures.ForEach(s => context.Factures.Add(s)); 
     context.SaveChanges(); 

     var lesPaiements = new List<Paiements> 
     { 
      new Paiements{montant=25,datePaiements=DateTime.Parse("2014-02-10"), ClientsId=1} 
     }; 
     lesPaiements.ForEach(s => context.Paiements.Add(s)); 
     context.SaveChanges(); 


    } 

} 

更新:我已經得到了該網站「跑」如果我可以用這個詞。我現在可以在線訪問應用程序,但只要嘗試使用MVC登錄功能登錄或創建新用戶,我會收到以下錯誤:

CREATE DATABASE權限在數據庫'master'中被拒絕。

在應用程序嘗試加載之前,我已經收到了錯誤信息,但我沒有得到它,因爲我將信任級別更改爲FULL。我不知道我在跟着這個!我只是想登錄他爲什麼試圖創造任何東西!

相關問題