This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
dev:csharp [2024/06/24 00:04] – adam | dev:csharp [2024/12/08 03:53] (current) – [entityframework (my beloved)] adam | ||
---|---|---|---|
Line 78: | Line 78: | ||
======= entityframework (my beloved) ======= | ======= entityframework (my beloved) ======= | ||
+ | |||
+ | install in your dev env: | ||
+ | |||
+ | dotnet tool install --global dotnet-ef | ||
install packages: | install packages: | ||
- | * Microsoft.EntityFrameworkCore.Design | + | |
- | * Npgsql.EntityFrameworkCore.PostgreSQL (or whatever you like) | + | * Npgsql.EntityFrameworkCore.PostgreSQL (or whatever you like) |
+ | |||
+ | dotnet-ef dbcontext scaffold " | ||
migrations: | migrations: | ||
- | | + | |
- | dotnet ef database update --connection " | + | dotnet ef database update --connection " |
- | + | ||
======= enum names ======= | ======= enum names ======= | ||
Line 139: | Line 146: | ||
</ | </ | ||
+ | also you can't not get '' | ||
======= why is asp.net not accepting my frombody thing? ======= | ======= why is asp.net not accepting my frombody thing? ======= | ||
Line 147: | Line 154: | ||
- '' | - '' | ||
- go find where services are being added; '' | - go find where services are being added; '' | ||
+ | |||
+ | ======= which is a field, which is a property? ======= | ||
+ | |||
+ | <code csharp> | ||
+ | public class MyClass | ||
+ | { | ||
+ | // this is a field. | ||
+ | private string _myField; | ||
+ | |||
+ | // this is a property. When accessed it uses the underlying field, | ||
+ | // but only exposes the contract, which will not be affected by the underlying field | ||
+ | public string MyProperty | ||
+ | { | ||
+ | get | ||
+ | { | ||
+ | return _myField; | ||
+ | } | ||
+ | set | ||
+ | { | ||
+ | _myField = value; | ||
+ | } | ||
+ | } | ||
+ | |||
+ | // This is an AutoProperty (C# 3.0 and higher) - which is a shorthand syntax | ||
+ | // used to generate a private field for you | ||
+ | public int AnotherProperty { get; set; } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | src: https:// |