ef code first - Entity Framework Inheritance share database fields -
so, using entity framework code first. model:
public class stockmove { public int id { get; set; } public int productid { get; set; } public virtual product product { get; set; } } public class stockmoveout : stockmove { public int customerid { get; set; } public virtual customer customer { get; set; } public int originlocalid { get; set; } public virtual local originlocal { get; set; } } public class stockmovein : stockmove { public int supplierid { get; set; } public virtual supplier supplier { get; set; } public int destinationlocalid { get; set; } public virtual local destinationlocal { get; set; } } public class stockmovetransfer : stockmove { public int originlocalid { get; set; } //should same stockmoveout public virtual local originlocal { get; set; } public int destinationlocalid { get; set; } //should same stockmovein public virtual local destinationlocal { get; set; } } public class datacontext : dbcontext { public dbset<stockmove> stockmoves { get; set; } }
i need refer fields (originlocalid, destinationlocalid) in stockmovetransfer same stockmovein , stockmoveout, entity framework expect new fields.
the sql ddl generated is:
create table [dbo].[stockmoves] ( [id] [int] not null identity, [productid] [int] not null, [customerid] [int] null, [originlocalid] [int] null, [supplierid] [int] null, [destinationlocalid] [int] null, [originlocalid1] [int] null, -- should not exists [destinationlocalid1] [int] null, -- should not exists [discriminator] [nvarchar](128) not null, primary key ([id]) );
well, how can configure entity framework point existing fields?
Comments
Post a Comment