December 3, 2023 at 5:06 pm
Hello everyone,
I am rather new to SQL-Server and got a problem to which I cannot find a solution.
But first to my project. I am developing a software with C# ef core and SQL-Server with the code first approach. Bothe get hosted by me via docker containers.
My current problem is that I want to change/update the DB schema. This works fine when I do this during development locally via the command ‚dotnet ef database update‘. Now I want to do this on my docker container SQl-Server which already contains data inside. Sadly I am not able to find a solution to this.
I would really appreciate some help here.
December 3, 2023 at 5:21 pm
Forgive my lack of Docker knowledge – I've never used it. How do you connect to your database from outside of Docker? Can you connect to it from VS?
The absence of evidence is not evidence of absence
- Martin Rees
The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
- Phil Parkin
December 3, 2023 at 5:36 pm
Hello SSC Guru,
first thanks for answer.
I connect to the DB in VS via a connection string. This works fine, meaning I can save and get data from the DB.
From outside in general I can connect via the IP and port of the hosting docker container. For example I use SQl Server Management Studio to check if the data was successfully saved.
Regardind to if I tried to resolve it on my own, yes I did. I tested if I could migrate it with the C# ef core methode Migrate(), tried finding souloutions online the last week and I could find any thing usefull.
December 3, 2023 at 6:03 pm
OK, that is good news.
In VS, take the following option:
Tools/SQL Server/New Schema Comparison
This will allow you to select your source database (local) and target (Docker version) and will then compare the two schemas, identifying differences and allowing you to push the changes from source to target to make them the same. I haven't done this in a while, so cannot remember the exact steps, but if you get stuck please post back and I will try to help further.
The absence of evidence is not evidence of absence
- Martin Rees
The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
- Phil Parkin
December 4, 2023 at 1:35 am
I could certainly be wrong but I'm not sure this can be done. I don't remember where I read it (mostly because I don't use containers, or at least not yet) but I was under the impression that they were, once created, immutable for structure and that you'd have to create a new one for any changes.
EDIT: I missed Phil's post above. Apparently I WAS WRONG.
--Jeff Moden
Change is inevitable... Change for the better is not.
December 4, 2023 at 8:15 am
IT WORKED!!!
Thank you so much!
December 4, 2023 at 8:18 am
The best way to migrate the DB to a new DB schema is as SSC Guru said.
VS --> Tools --> SQL Server --> New Schema Comparison ...
Select Source and Target SQL Server, Compare, Update
December 4, 2023 at 9:01 am
This was removed by the editor as SPAM
December 4, 2023 at 9:03 am
This was removed by the editor as SPAM
December 4, 2023 at 2:18 pm
🙂
--Jeff Moden
Change is inevitable... Change for the better is not.
December 4, 2023 at 11:41 pm
very very disappointed at this unholy situation. How is it possible that Jeff is wrong!!!!
Heh... and freely admitted it. 😀 Serves me right for interjecting on something that I wasn't absolutely sure of.
--Jeff Moden
Change is inevitable... Change for the better is not.
December 5, 2023 at 8:49 am
very very disappointed at this unholy situation. How is it possible that Jeff is wrong!!!!
Every once in a while, he does this, just to prove he actually is human 😉
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data/code to get the best help[/url]
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution 😀
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
December 5, 2023 at 11:35 pm
frederico_fonseca wrote:very very disappointed at this unholy situation. How is it possible that Jeff is wrong!!!!
Every once in a while, he does this, just to prove he actually is human 😉
And, on top of all that, I'm getting old and NASA has just declared me to be a major source of methane. 😀
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 15 posts - 1 through 15 (of 16 total)
You must be logged in to reply to this topic. Login to reply