0

So I want to make a local DB access so I can play with data as much as I want without messing up the real DB.

I have a folder with DBScripts and it contains scripts in numerical order that I need to run.

enter image description here

I can't find any information on how to execute them in order and all at once. (If that is how its done)

I'm using a local SQL DB Server as I write in C# using RAZOR PAGES.

I currently have made a database and have a connection to it and I can see a basic table that has been created for me.

enter image description here

Now I don't have a clue where to go from here or maybe there is a few steps I missed in the beginning that I could use as I saw one of the options in my command line.

After using (dotnet ef migrations) command I can see a list of commands that I can use.

enter image description here

I wonder if that is of any use to me?

If you have any article I can refer to for this problem would be much appreciated.

1
  • 1
    If you're using a code first approach, then you should really seed your data as described here, if you're using a database first approach, then you'll probably want to execute the SQL manually on the server. It is possible to execute raw SQL but you can only do that on a per table level, so you'll need to build a system that identifies which table to run the SQL on and then map that to your DbSet<> in your code Commented Mar 21, 2022 at 15:08

1 Answer 1

1

Along the lines of MindSwipe second suggestion, you can execute the scripts via the command line as well. Check here for how to do this. In my projects, I have built batch files that can I execute as part of a program installation or build process. I used cake to script this out, but there are many other ways to run sql in this way.

Sign up to request clarification or add additional context in comments.

1 Comment

I will give it a try once I fixed an amazing issue where I was using Microsoft SQL instead of MySQL which is what the scripts are written for... Your answer contains a lot of useful information that I was looking for.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.