SQLServer in repositories

0

I have to send a project of an application through a GitHub repository, I was able to make the application work perfectly front-end, back-end and LOCAL database, my doubt is:

How can I export SQLServer to a repository? Or do I have to put it on some server for the application to just be downloaded and executed?

    
asked by anonymous 15.10.2017 / 05:21

1 answer

1

It has several forms, it depends on how you are working. When you work with Code First + Migrations your database will be created automatically, migrations generates the scripts and controls the versions of the database. I think you're not using the features listed above, but here's the hint for upcoming projects:)

For your current project, the best way is to generate the scripts and do this authoring control manually. To generate the scripts in SQL Server Management Studio, right click on the database > Tasks > Generate scripts, select all tables and the place to export.

After this, put this script in a class of your project and when you start your connection to the bank do a check or an exception handling to validate if the database does not exist (each connectionstring model asks for a different approach if you have the name of the database in your connectionstring will have to handle the exception), so if the database does not exist, it runs the database creation script. Also create a class with the insert scripts to run right after the database is created.

    
15.10.2017 / 08:22