Sqlserver in repositories

Asked

Viewed 41 times

0

I have to send an application project through a Github repository, I managed to make the application work perfectly front-End, Back-End and LOCAL database, my doubt is:

Can I export Sqlserver to a repository? Or will I have to put it on some server for the application to only be downloaded and run?

  • Do you want to send the bank? Why not send your structures (tables and views) and programming (triggers, functions and procedures)? Or do you want to send data as well? The best of the worlds is you, for this type of distribution and maintenance, have the sql scripts for creating the objects and inserting the data in the project

  • I would like whoever downloads my application just run the solution and ready, at the moment if I run it on another computer it runs but without doing the GET, POST, etc on Sqlserver.

  • And I ended up not answering the question... I would like it to already be a data yes, but it is not something so fundamental. I will give a search on SQL scripts, if you have any documentation I will be grateful.

1 answer

1


There are several ways, depending on how you are working. When working with Code First + Migrations your database will be created automatically, Migrations generates the scripts and controls the versions of the database. I believe you are not using the resources mentioned above, but the tip for next projects :)

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

After that, you place this script in a class of your project and when you start your connection with the bank do a check or an exception treatment to validate if the database does not exist (Each connectionstring model asks for a different approach, if it has the database name in its connectionstring it will have to handle the exception), then if there is no database, it runs the database creation script. Also create a class with insert scripts to run immediately after database creation.

  • About putting the script into classes, I’m not favorable. I’d rather leave it in a Asset separate, but I think it depends on the taste of each.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.