How to connect a Code First Model Database to a GoDaddy remote Database?http://forums.asp.net/t/1798252.aspx/1?How+to+connect+a+Code+First+Model+Database+to+a+GoDaddy+remote+Database+Wed, 02 May 2012 00:47:36 -040017982524957152http://forums.asp.net/p/1798252/4957152.aspx/1?How+to+connect+a+Code+First+Model+Database+to+a+GoDaddy+remote+Database+How to connect a Code First Model Database to a GoDaddy remote Database? <p>Hey Guys.</p> <p>The title pretty much says it all.</p> <p>I have created a Database in MVC 3 with the Code First Entity Framework and I am almost ready to deploy but i have no clue on how to Deploy the database?</p> <p>I do not need the data inside of it since it was just dummy data but i do not know how to edit the webconfig file to point to the database.</p> <p>any help vwould be awesome !</p> 2012-04-29T19:50:44-04:004957167http://forums.asp.net/p/1798252/4957167.aspx/1?Re+How+to+connect+a+Code+First+Model+Database+to+a+GoDaddy+remote+Database+Re: How to connect a Code First Model Database to a GoDaddy remote Database? <p>You can add an entry under &lt;connectionStrings&gt; in the .config, as with any other DB code, but with code-first the name just has to match the name of your DbContext-derived class. Also as another approach, you can pass a name into the DbContext ctor in the form &quot;name=Foo&quot; where &quot;Foo&quot; is the name you set in the &lt;connectionStrings&gt; section.</p> 2012-04-29T20:38:32-04:004957174http://forums.asp.net/p/1798252/4957174.aspx/1?Re+How+to+connect+a+Code+First+Model+Database+to+a+GoDaddy+remote+Database+Re: How to connect a Code First Model Database to a GoDaddy remote Database? <p>Could i maybe get a example i think thats the problem i am having i know i have to pass that dbcontext to the connection string in webconfig i just dont know how to set that up...</p> <p>Here is part of my model.</p> <pre class="prettyprint">public class CareersConsoleDBContext : DbContext { public DbSet&lt;CareersConsole&gt; CareersConsole { get; set; } }</pre> <p>thats where the model tells it to connect it to a db</p> <p>here is part of my webconfig.</p> <pre class="prettyprint">&lt;connectionStrings&gt; &lt;add name="CareersConsoleDB" connectionString="Data Source=|DataDirectory|CareersConsole.sdf" providerName="System.Data.SqlServerCe.4.0"/&gt; &lt;add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient"/&gt; &lt;/connectionStrings&gt;</pre> <p>I tried to rename it accordingly but im not even sure its reading the file?..is there a way to make the connection between the two?<br> <br> </p> <p><br> <br> </p> 2012-04-29T20:50:55-04:004957179http://forums.asp.net/p/1798252/4957179.aspx/1?Re+How+to+connect+a+Code+First+Model+Database+to+a+GoDaddy+remote+Database+Re: How to connect a Code First Model Database to a GoDaddy remote Database? <p>For this DbContext:</p> <pre class="prettyprint">public class PetsDB : DbContext {...}</pre> <p>I would need this in my .config:</p> <pre class="prettyprint"> &lt;connectionStrings&gt; &lt;add name="PetsDB" connectionString="server=..." providerName="..." /&gt;</pre> <p>And the other approach I said, you can do this:</p> <pre class="prettyprint"> public class PetsDB : DbContext { public PetsDB(string name) : base(name) { } ... } var db = new PetsDB("name=Foo");</pre> <p>And then in the .config you could have:</p> <pre class="prettyprint"> &lt;connectionStrings&gt; &lt;add name="Foo" connectionString="server=..." providerName="..." /&gt; </pre> <p><br> <br> </p> 2012-04-29T20:56:12-04:004957194http://forums.asp.net/p/1798252/4957194.aspx/1?Re+How+to+connect+a+Code+First+Model+Database+to+a+GoDaddy+remote+Database+Re: How to connect a Code First Model Database to a GoDaddy remote Database? <p>I still cant get the stupid thing to work.</p> <p>I created a MS SQL database and got the provider name and the connectionstring from godaddy to input into my webconfig.</p> <p>then i did what you said to do with the controller (basically name it the same as my db context into my webconfig file)</p> <p>is there anything else that could be making the problem?..Like i said i ran this already on my localhost with Code First and it ran perfectly b ut trying to get this into production its not working everytime it saysing that it has encountered a error.</p> <p>But i did notice something different..the timeout was alot faster this time around rather then when i had nothing so im thinknig its created and connected but im not sure if I actually have to build the database first or if the code first still builds it</p> 2012-04-29T21:39:01-04:004957196http://forums.asp.net/p/1798252/4957196.aspx/1?Re+How+to+connect+a+Code+First+Model+Database+to+a+GoDaddy+remote+Database+Re: How to connect a Code First Model Database to a GoDaddy remote Database? <p>So the above connection string works with a local DB but not one hosted elsewhere? If that's the case, check for firewall issues or if their DB is even listening (Sql Server is on port 1433 by default). Not much else I can suggest or think of if it's environmental.</p> <p></p> 2012-04-29T21:45:38-04:004960655http://forums.asp.net/p/1798252/4960655.aspx/1?Re+How+to+connect+a+Code+First+Model+Database+to+a+GoDaddy+remote+Database+Re: How to connect a Code First Model Database to a GoDaddy remote Database? <p>You can see a sample connection string that works on Go Daddy shared hosting <a href="http://support.godaddy.com/help/689"> here</a>.&nbsp;</p> 2012-05-02T00:47:36-04:00