I have (with the help of some other users on here) built a simple blog application in MVC3, which I plan to use as my personal website. It currently works fine locally on my machine, but I know there will be major obstacles that will come with trying to upload it online (GoDaddy).
Basically my question is…
What is the best way to upload and activate an MVC3 site? How does that work with regard to Code First? Should I technically be creating the tables in SQL Server before? If I want to make changes to the tables after, I will just lose all my data that I have online (assuming I don’t seed everything I do constantly).
I suppose my major concern is that I really just want to get this site up and running online, but I still have tons of work to do on it. I want to be able to post blog posts about the sites progress on the site itself, so I don’t want to lose any of that data when I change things around.
I apologize as I am quite new to this, so thank you in advance!
You can let Entity Framework create the tables for you the first time, but you should disable it from dropping your database later. The best way to do this is by using Entity Framework’s database migrations, which creates code containing the latest changes. By executing that code you will only perform those actions, without dropping the entire database. You can also let database migrations generate SQL statements so you can do this via SQL Management Studio (SSMS).
Check out this simple example of EF’s Database Migrations: http://www.davidhayden.me/blog/asp.net-mvc-4-and-entity-framework-database-migrations