-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Learnings.txt
24 lines (21 loc) · 1.59 KB
/
Learnings.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
1. To eliminate the warnings from nullable reference types, remove the following line from the csproj file:
<Nullable>enable</Nullable>
2. The scaffolding engine currently does not support nullable reference types, therefore the models used in scaffold can't either.
Remove the ? nullable reference type annotation from public string? RequestId { get; set; } in Pages/Error.cshtml.cs so the project
builds without compiler warnings.
3. The EnsureCreated method takes no action if a database for the context exists. If no database exists, it creates the database and schema.
EnsureCreated enables the following workflow for handling data model changes:
Delete the database. Any existing data is lost.
Change the data model. For example, add an EmailAddress field.
Run the app.
EnsureCreated creates a database with the new schema.
4. This workflow works early in development when the schema is rapidly evolving, as long as data doesn't need to be preserved.
The situation is different when data that has been entered into the database needs to be preserved. When that is the case, use migrations.
5. The async keyword tells the compiler to:
Generate callbacks for parts of the method body.
Create the Task object that's returned.
The Task return type represents ongoing work.
The await keyword causes the compiler to split the method into two parts. T
he first part ends with the operation that's started asynchronously.
The second part is put into a callback method that's called when the operation completes.
ToListAsync is the asynchronous version of the ToList extension method.