Entity Framework Core Part 4

Play Entity Framework Core Part 4

The Discussion

  • User profile image
    rcroeder
    With joins, I prefer to create views and then create a class of that view and add that class it to the dbContext. The sending that view (sql) into the tuning advisor to improve the performance. Another trick I use is since I really only use Database First in Core, is to change the classes being built bt=y the scaffolder to partial and create a mm.uc.cs to match the generated mm.cs class. I also create a dbContext.uc.cs to hold the views.This file contains OnConfiguring(DbContextOptionsBuilder optionsBuilder) which gets the connection string from a secure place. The third thing that I is I keep track of all of the tables/fields in a separate db so i can store the DisplayName an add that to the class.
    [StringLength(200)]
    [DisplayName("Address City Title")]
    public string AddressCityTitle { get; set; }

    And the [Key] attribute.

    Using the .uc.cs for User Custom code allow me to run the scaffolding anytime without fear.

    This is all done post scaffolding with a utility I wrote utility

    It is nice seeing this series because it validates my design process. Most use Model First which lacks the depth Database First.

Add Your 2 Cents