2021年1月1日星期五

Primary key inheritance in .NET Core

I have a base class BaseFunction:

public class BaseFunction      {          [Key]          public int BaseFunctionID { get; set; }          public string Name { get; set; }      }  

I also have a derived class 'ObjectiveFunction`:

public class ObjectiveFunction : BaseFunction      {          public bool IsMax { get; set; }      }  

When I try to build a migration, I get the error: "The entity type 'ObjectiveFunction' requires a primary key to be defined.

I was under the assumption the primary key would be defined by the base class ObjectiveFunction extends. Am I misunderstanding how to set this up or do I have something else going on (un-synced migrations, for example?)

https://stackoverflow.com/questions/65524474/primary-key-inheritance-in-net-core January 01, 2021 at 02:30AM

没有评论:

发表评论