Skip to content

ayanNullPointerEx/EfExample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Entity Framework Introduction

Basic Program to -

  • Connect to Postgres DB
  • Code-First approach in creating Table
  • Read/Write operation to DB

Version -

  • version 1.0.0 - Basic EF Framework
  • version 2.0.0 - Adding Seed Data

Steps -

  1. Run postgres DB n check via pgAdmin UI
        docker run --name postgres -e POSTGRES_PASSWORD=password -p 5432:5432 -d postgres:latest
        docker run -p 80:80 -e 'PGADMIN_DEFAULT_EMAIL=user@domain.com' -e 'PGADMIN_DEFAULT_PASSWORD=SuperSecret' -d dpage/pgadmin4

Note: Command to get Database Hostname used in pgAdmin

 docker inspect <postgres-dockerContainerId> | grep IPAddress
  1. Install EF Framework (if not already installed)
        dotnet tool install --global dotnet-ef
  1. Create Migration script using -
        dotnet ef migrations add InitialState

        dotnet ef database update
  1. Run the program.

Output -

img.jpg