Giter Club home page Giter Club logo

codesanook-ef-note's Introduction

codesanook-ef-note

How to run the project locally

  • Fork this project
  • Clone the project to your computer. !!! Change {your-github-username} to your GitHub username.
    $ git clone [email protected]:{your-github-username}/codesanook-ef-note.git
  • CD to to the root folder.
    $ cd codesanook-ef-note
  • Launch Docker containers.
    $ docker compose down --volumes; docker compose up --build
  • Wait for a while until you see dotnet watch messages, e.g.
    web_1  | info: Microsoft.Hosting.Lifetime[0]
    web_1  |       Now listening on: http://[::]:8000
  • Open a browser and navigate to http://localhost:8000/.
  • You will find a simple note app that you can:
    • Add a new notebook which is a group/container of each note.
    • Add a new note.
    • Add a new tag.
    • Update/Delete notebook, note and tag.

Hot reload

  • Edit some C# source code in src/Codesanook.EFNote folder.
  • Code will be compile automatically.
  • Refresh a browser and see what you have changed.

EF Note in a browser

ef-note-animated-screenshot.gif

Release compose for testing only

docker-compose down --volumes; docker-compose -f docker-compose.yml -f docker-compose.release.yml up --build

Production release

Create a new App Service

  • Create Azure App Service with a container
  • Use DockerHub registry and mcr.microsoft.com/dotnet/samples:aspnetapp image
  • Check log in deployment, open a browser and navigate to https://{your-app-service-name}.azurewebsites.net/
  • You should find an example ASP.NET Core MVC app

Set some configurations

  • Set these configurations to your app service:
    • WEBSITE_WEBDEPLOY_USE_SCM
      • true
    • WEBSITES_PORT
      • 8000
    • CONNECTIONSTRINGS__DEFAULTCONNECTION
      • Server={your-server-name}.mysql.database.azure.com; Port=3306; Database={your-database-name}; Uid={your-username}@{your-server-name}; Pwd={your-password}; SslMode=Preferred;CharSet=utf8mb4;
  • More details for Npgsql SSL connection https://www.npgsql.org/doc/security.html#encryption-ssltls

Create DockerHub repository and get a new token

  • Create a public DockerHub repository
  • Get DockerHub token from Account Settings > Security > New Access Token

Create GitHub secret

  • Download publish profile from your App Service and use it a value of AZURE_WEBAPP_CONTAINER_PUBLISH_PROFILE secret
  • Create these GitHub secrets with their values:
    • AZURE_WEBAPP_CONTAINER_PUBLISH_PROFILE
    • AZURE_WEBAPP_NAME
    • DOCKERHUB_REPOSITORY
    • DOCKERHUB_TOKEN
    • DOCKERHUB_USERNAME

Trigger GitHub Actions

  • Go to GitHub Action tab and enable it
  • Create new commit and push the project to the main branch

Debugging

  • CD to src/Codesanook.EFNote folder and launch the app with debugging .NET Core launch (web).
  • Start only a database container at root level folder.
    docker compose up mysql
    # or
    docker compose up mssql

Presentation

In memory creative

dotnet add package Microsoft.EntityFrameworkCore.InMemory

Create empty solution file

dotnet new sln --name Codesanook.EFNote

Add existing project to a solution file

dotnet sln add ./Codesanook.EFNote/Codesanook.EFNote.csproj

Work with database migration

  • CD to root of the project
    $ cd src/Codesanook.EFNote
  • Install additional required package.
    $ dotnet add Microsoft.EntityFrameworkCore.Design
  • Create your first migration file.
    $ dotnet ef migrations add InitialCreate --project src/Codesanook.EFNote
  • Apply migrations to a database.
    $ dotnet ef database update
  • Remove migration files.
    $ dotnet ef migrations remove
  • Update the tool
    $ dotnet tool update --global dotnet-ef

TODO

  • Global exception
  • Deploy to a cheap MySQL server
  • Better logging to console
  • Improve code quality
  • Use async/await

Issues

  • ExecuteUpdate fails when target entity has an owned entity
  • Can't view change log, temporal table

codesanook-ef-note's People

Contributors

aaronamm avatar ponggun avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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