Reputation: 338
I'm using Visual Studio Enterprise 2015, along with the Github plugin.
For a assignment I have to use C# with a database, which isn't a problem within VS. But, I want to check the local database into the repository, so I can work on the project on multiple computers.
I'm the only one who will use this repository (it's private). There won't be changes apart from my own.
I know it's not really meant to do this, but I really would like to remain working with local databases for simplicity purposes.
I've found this answer on the topic, but I'm not sure what he's trying to say.
Upvotes: 1
Views: 2118
Reputation: 1212
I do really thank you for asking such a beautiful question that opened my mind . And I found this blog and it really explains how to do this job . And I realized that I will be needing this :) . Please check out the synchronizing-a-mysql-database-with-git-and-git-hooks Hope this helps .
Upvotes: 1
Reputation: 114671
When you use Visual Studio together with SQL Server Developer tools you can have your database schema and initial data scripted out as a Visual Studio project. You'd then use the Visual Studio project to define what the database looks like and you can then use the project to create a SQL Server LocalDB or SQL Server Express database on demand when you restore your project. You can sync the schema between your local database and the Visual Studio project. And commit the difference to git.
Alternatively you could use something like Entity Framework to define your database schema or use Entity Framework Code First annotations to map your object model to a database schema. Combined with Entity Framework Migrations and Entity Framework Data Initializers you can instruct you application to rebuild the database at startup time should it be missing.
Using Git pre-commit hooks on Windows is not the easiest thing to setup and Visual Studio 2012-2015 won't execute your hooks, you'd have to do all your git operations through the commandline for these hooks to start working. Visual Studio 2017 uses the git.exe commandline tool and should be able to run your hooks, though support for hooks is still limited if you're using a normal command shell instead of a bash shell (linux shell). Most hooks are implemented as Linux shell scripts or other scripting languages that are not always fully supported on Windows.
Depending on the file size, you could always just commit the database file itself, the binary files. Though git generally doesn't like binaries, nothing prevents you from committing the latest state and transferring it to another machine this way.
Upvotes: 1
Reputation: 376
I usually but the instructions to build the database into the repository, either a .sql file or a script to execute the commands needed to restore the database.
A database like sqlite is stored in only one file, that you could easily put in your git repository.
If your looking for more concrete ideas, you might want to share what database your working with.
Upvotes: 0