Gilles TOURREAU
Gilles TOURREAU
CC#
Created by Kabiigon on 10/15/2024 in #help
✅ cleanup
@Kabiigon you can also replace -Force by WhatIf if you want to check on the output what will be delete.
6 replies
CC#
Created by Kabiigon on 10/15/2024 in #help
✅ cleanup
I use the following PS command:
Get-ChildItem -Recurse -Directory -Include obj, bin | Remove-Item -Recurse -Force
Get-ChildItem -Recurse -Directory -Include obj, bin | Remove-Item -Recurse -Force
6 replies
CC#
Created by culture on 10/14/2024 in #help
Migration issues -EF core.
I just look some of my code, and I understand now why I put public setter for navigation properties... If I set them private, sonar will raise a S1144 warning that the private setter is not used...
15 replies
CC#
Created by culture on 10/14/2024 in #help
Migration issues -EF core.
Oh yes sorry, I just read in the MS documentation that the setter can be private for navigation properties.
15 replies
CC#
Created by culture on 10/14/2024 in #help
Migration issues -EF core.
For the navigation properties ?
15 replies
CC#
Created by culture on 10/14/2024 in #help
Migration issues -EF core.
The MS documentation is enough: For example, read this page : https://learn.microsoft.com/en-us/ef/core/modeling/constructors and this one https://learn.microsoft.com/en-us/ef/core/modeling/relationships/navigations, you will see the limitation of navigation property. If you want to do a real domain implementation, I advice you to create : - Your domain with entities as you really want (with OO style, constructor, value objects,...). - Create entities for EF which will be used only to query / persist your entity of the domain. You can use manual mapping between the model and EF Entity or a mapper like auto mapper. We use this approach in my project, because: - I want to use a real domain that reflect our business rules / entities. - I don't want that developers deform our domain, because EF have limitations of the design for the entities. We use only EF entities to persist data and query using Linq. With this approach, of course you will have the fellling to copy/paste entities of your domain to create EF entities. But with this approach, you can make your domain entities independant of the structure of the SQL tables that you want to query/persist. Specially, it is very interesting when you have complex n-n relationship in your domain and you want to persist it differently in your database (with a JSON column for example,...). In my projects, my teams make the EF entities as internal and are limited to the infrastructure/persistance layers and we suffix it with the Db name to avoid conflict with the domain entities and EF entities class names when doing the mapping. And last thing, when doing this approach, it is easy to perform unit tests for our domain and our repositories separately.
15 replies
CC#
Created by culture on 10/14/2024 in #help
Migration issues -EF core.
EF required public setter properties, you can't define the properties with private setters.
15 replies
CC#
Created by culture on 10/14/2024 in #help
Migration issues -EF core.
Just remove the constructor with arguments, and set the navigation properties with public getter/setter. For example:
public Customer? Customer { get; set; }
public Customer? Customer { get; set; }
15 replies
CC#
Created by culture on 10/14/2024 in #help
Migration issues -EF core.
Can you show the Order class C# code? Normally, you should not put related entities (Customer and Location) in the constructor parameters...
15 replies