https://github.com/kolosovpetro/databasefirstentityframeworkcore
Simple example of Database-First approach using Entity Franework Core.
https://github.com/kolosovpetro/databasefirstentityframeworkcore
database-first ef-core efcore entity-framework entity-framework-core mssql-database postgresql
Last synced: 7 months ago
JSON representation
Simple example of Database-First approach using Entity Franework Core.
- Host: GitHub
- URL: https://github.com/kolosovpetro/databasefirstentityframeworkcore
- Owner: kolosovpetro
- Created: 2020-12-26T19:41:43.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-12-26T20:06:57.000Z (almost 5 years ago)
- Last Synced: 2025-01-16T06:15:40.531Z (9 months ago)
- Topics: database-first, ef-core, efcore, entity-framework, entity-framework-core, mssql-database, postgresql
- Language: C#
- Homepage:
- Size: 9.77 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Database First with Entity Framework Core
Simple example of Database-First approach using Entity Franework Core.
## Packages required
- `Microsoft.EntityFrameworkCore.Design`
- `Npgsql.EntityFrameworkCore.PostgreSQL`
- `Microsoft.EntityFrameworkCore.SqlServer`## CLI commands
- `dotnet ef dbcontext scaffold "Data Source=DESKTOP-P87PH2B;Initial Catalog=CodeFirstEntityFramework;Integrated Security=true;" Microsoft.EntityFrameworkCore.SqlServer -o SqlServerScaffold`
- `dotnet ef dbcontext scaffold "Server=localhost;User Id=postgres;Password=postgres;Database=CodeFirstEntityFramework;" Npgsql.EntityFrameworkCore.PostgreSQL -o PostgreSqlScaffold`
## Use case
Consider the case when we have a connection string to some database we want to reverse engineer.
Consider the database [CodeFirstEntityFrameworkCore](https://github.com/kolosovpetro/CodeFirstEntityFrameworkCore)
We have following connection strings:
- `"Server=localhost;User Id=postgres;Password=postgres;Database=CodeFirstEntityFramework;"`
- `"Data Source=DESKTOP-P87PH2B;Initial Catalog=CodeFirstEntityFramework;Integrated Security=true;"`Using the commands:
- PostgreSQL:
`dotnet ef dbcontext scaffold "Server=localhost;User Id=postgres;Password=postgres;Database=CodeFirstEntityFramework;" Npgsql.EntityFrameworkCore.PostgreSQL -o PostgreSqlScaffold`
- MS SQL Server:
`dotnet ef dbcontext scaffold "Data Source=DESKTOP-P87PH2B;Initial Catalog=CodeFirstEntityFramework;Integrated Security=true;" Microsoft.EntityFrameworkCore.SqlServer -o SqlServerScaffold`