-
Notifications
You must be signed in to change notification settings - Fork 0
/
Instructions.txt
53 lines (44 loc) · 1.9 KB
/
Instructions.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# Code First
## Enable Migrations
Set Package Manager Console project to ...DataAccess
EntityFrameworkCore\Enable-Migrations
## Add Database Migration
Set Package Manager Console project to ...DataAccess
EntityFrameworkCore\Add-Migration 0001-InitialMigration
## Update Database (Publish)
Set Package Manager Console project to ...DataAccess
EntityFrameworkCore\Update-Database –verbose
## One Line Drop + Recreate
update-database -TargetMigration:0 | update-database -force
## Reverse Engineer (From DB)
Right Click Project
Select "EF Core Power Tools"
Click "Reverse Engineer"
Select Excellence.Ims.Database from "Choose SQL Server Database Project (.dacpac)"
Check "Use EF Core 5 (preview)" and click ok
## Using WebApp Project
Running the WebApp project will automatically publish the database and any new changes(?)
To publish the database, the proposed solution is
1) Add Migration on DataAccess Project (updates the local DB model)
2) Run the WebApp Project (publishes the updated model to the server DB)
# Database First
## Publish Database
Right Click Project
Click "Publish..."
Fill in the server information
OR just double click Excellence.Ims.Database.publish.xml
## Create Diagram
Right Click Project
Select "EF Core Power Tools"
Click "Add DbContext Model Diagram"
Open the created .dgml file
# Razor Pages
## Create Scaffolding
Create a Students folder in the Pages folder.
In Solution Explorer, right-click the Pages/Students folder and select Add > New Scaffolded Item.
In the Add Scaffold dialog, select Razor Pages using Entity Framework (CRUD) > ADD.
In the Add Razor Pages using Entity Framework (CRUD) dialog:
In the Model class drop-down, select Student (ContosoUniversity.Models).
In the Data context class row, select the + (plus) sign.
Change the data context name from ContosoUniversity.Models.ContosoUniversityContext to ContosoUniversity.Data.SchoolContext.
Select Add.