IT:AD:Code First:Entities:Classes
CheckList: Classes Design
- MUST: Parameter less constructor
- MUST: Not be sealed or abstract
- MUST: Have a PK.
- Convention: Named
Idor<Entity>Id - DataAnnotation:
[Key()](see Annotations) - FluentAPI:
modelBuilder.Entity<Person>().HasKey(ma => ma.SSN);(see IT:AD:Code First:FluentAPI:Properties)
* COULD:Table Name mapping can be forced by:
- DataAnnotation:
[ClassName](see Annotations): - FluentAPI: within
DataContext.OnModelCreating():modelBuilder.Entity<Invoice>().Property(i => i.Name) .HasColumnName("ClientInvoices");(see IT:AD:Code First:FluentAPI):- Note: For more complex mapping: http://bit.ly/tjUwK8
- CONSIDER: You can exclude entities:
- DataAnnotation:
[NotMapped](see IT:AD:Code First:DataAnnotations) - FluentAPI: within
DataContext.OnModelCreating():modelBuilder.Ignore<Invoice>()(see IT:AD:Code First:FluentAPI) Example:
modelBuilder.Entity<X>.MapSingleType().ToTable("xyxTable");
- CONSIDER: Watch out for design flaw of making Entitities into Anemic Entities
- Consider using Partial or Extension Methods to contain Domain Logic in Entities rather than forcing it to be included in the Application Layer outsider of the Domain Layer.
_graphContext.Configuration.AutoDetectChangesEnabled = false;