Reputation: 7758
We are a team of two developers, building an ASP.Net MVC app in Azure and are wondering what is the best way to go about setting up the database.
We had been using a local db in the App_Data folder that attached to SQL Express, this seemed to be working fine until it came time to check in and conflicts occur.
We are using git to check into BitBucket and a deployment is ran off the master branch into Azure deploying the database as well.
We were/are using database code first migrations and all the data is seeded.
Can anyone help please?
Upvotes: 2
Views: 342
Reputation: 3641
Moving the discussion to an answer.
Regarding migrations:
I work in a team of 2 developers too. What works for us is at the early stages of development (model changes a lot) each one runs its own database locally (data seeded in the initializer). Once the project is relatively stable, we deploy to a website with a SQL Azure database. Whenever the model changes, we add a migration and run it against that database. Our team, like yours is small so this works for us. If the team grows, I recommend setting up a CI server (Team City).
Regarding Database connections
We don't use the .mdf file in App_Data. Each one has a local instance of SQL server Express running in their machine. For the connection strings, we have 4 environments set up (Local, Development, Staging, Production). These are set in the web.config (you can set them up in code too it's your choice). When we ran the application, we choose the environment we want to develop against. We deploy using VS2013 to an Azure Website, each web.config is configured accordingly per environment.
We get the environment from the web.config and depending on which environment we're at, the connection string is injected into the application using an IOC container (Ninject).
<configuration>
<appSettings>
<add key="environment" value="Development"/>
</appSettings>
</configuration>
Hope this helps,
Upvotes: 1