GithubHelp home page GithubHelp logo

paraspatidar / ef-migration-strategy Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 23 KB

various devops specific options for ef data migration

License: MIT License

C# 89.25% Dockerfile 8.02% Makefile 2.73%

ef-migration-strategy's Introduction

Ef core migration demo

This repo contains 3 diffrence type of varities on how someone can migrate and update the database based on the ef / efocre based contexts and entities. Three aproaches mentioned here are :

Project Sample Description
stand-alone-data-project-sourcecode-based standard old school way of copying all source files and then running ef tool commands
stand-alone-data-project-customapp-based customer application which reated a docker image which as soon as starts , does the data migration
stand-alone-data-project-efbundle-based The devops friendly *best way *where migration bundle is created and it gets deployed which doest the job.

Each inidivusual folder has its own docker compose file , source code and docker file. Docker compose build the project , creates docker image and then spin up the container. if you are making changes to source code , please dont forget to refresh image or rebuild image when running docker compose via docker-compose up --build

Rest of the details and steps are as per each type of project and can be seen inside project's readme file.

Postgresql

This samples uses postgresql for illustration purpose (as ef core is compatible not just with mssql but various other dbs ) Thus the docker compose file contains the postgre db as well as its UI tool (pg admin) docker images.

Resource Running on
postgressql db http://localhost:5435
pg admin web http://localhost:5050
Steps to connect to pg admin to view DB changes
  1. Open PG admin web( http://localhost:5050)
  2. On Main Web UI use credentials mentioned in docker compose file i.e username/email as [email protected] and password as root.
  1. Now , once inside the portal , connect to locally running postgresql by providing the container name(as db) and other details as per docker compose file i.e username postgres and password as postgres.
  1. connect to db , expand as per image and reach till schemas --> tables and you will be able to view tables and schemas.

How this project was created by adding migration and updating db from VS studio

  1. Lets say you are inside the stand-alone-data-project-sourcecode-based
  2. open Developer powershell as shows below from VS
  1. Navigate to DataProject folder
  2. Run command to add initial migration dotnet ef migrations add InitialDbMigration -c CustomerManagementDbContext -o Migrations
  1. It will create model snapshot and initial migration files.
  2. Now lets say you add one more column in model , so add migration for that dotnet ef migrations add AddedNewColumn -c CustomerManagementDbContext -o Migrations
  1. You will see that this new migration is also added.

  1. Now you can run docker compose and it will build and deploye those migrations.
  1. You will see that docker images are build , db image spin up and migration applied.
  1. This build steps , process and migration apply will very based on which type of above 3 mentioned project sample are you running.

ef-migration-strategy's People

Contributors

paraspatidar avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.