inheritance - EF Core inherited properties not being reflected in migration script -


i trying migrate below models , inheritance not being reflected in migration script generated. missing? using pm handle migration script generation simple add-migration followed update-database in vs2017 targeting sql 2016.

public class facility     {         [key]         public int id { get; set; }         public bool deleted { get; set; }         public string name { get; set; }         public string description { get; set; }         public byte? image { get; set; }          public list<locationfacility> locationfacilities { get; set; }     }      public class helipad : facility     {         public decimal size { get; set; }         public decimal maximumweight {get; set;}     } 

based on documentation of ef core,

in order have type included in model convention, either need dbset property or navigation property pointing type or refer in onmodelcreating. there navigation property on facility class. perhaps inverse navigation pointing facility on type included in model caused facility included. helipad not added unless explicitly refer it. ef core sets tph types included in model & have hierarchy. not try find types in hierarchy if not included.

to fix issue, easiest way add dbset property type want include in derived class of dbcontext. if don't want expose dbset property type can write following in onmodelcreating method.

modelbuilder.entity<helipad>(); 

hope solves issue.


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -