Migrating DB to new DB schema

  • 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.

  • 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?

     

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

  • 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.

  • 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.

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

  • 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


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • IT WORKED!!!

    Thank you so much!

  • 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

  • Jeff Moden wrote:

    Apparently I WAS WRONG.

    I'm framing this! 🙂

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

  • This was removed by the editor as SPAM

  • This was removed by the editor as SPAM

  • Phil Parkin wrote:

    Jeff Moden wrote:

    Apparently I WAS WRONG.

    I'm framing this! 🙂

    🙂

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Jeff Moden wrote:

    Phil Parkin wrote:

    Jeff Moden wrote:

    Apparently I WAS WRONG.

    I'm framing this! 🙂

    🙂

    very very disappointed at this unholy situation. How is it possible that Jeff is wrong!!!!

  • frederico_fonseca wrote:

    Jeff Moden wrote:

    Phil Parkin wrote:

    Jeff Moden wrote:

    Apparently I WAS WRONG.

    I'm framing this! 🙂

    🙂

    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


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • frederico_fonseca wrote:

    Jeff Moden wrote:

    Phil Parkin wrote:

    Jeff Moden wrote:

    Apparently I WAS WRONG.

    I'm framing this! 🙂

    🙂

    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

  • Johan Bijnens wrote:

    frederico_fonseca wrote:

    Jeff Moden wrote:

    Phil Parkin wrote:

    Jeff Moden wrote:

    Apparently I WAS WRONG.

    I'm framing this! 🙂

    🙂

    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


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 15 posts - 1 through 15 (of 16 total)

You must be logged in to reply to this topic. Login to reply