c# - scaffold Many to Many Relation with nullable key -


i got table 3 1 many relations (one many many relation , third 1 many relation data), want scaffold relationships 1 side of many many relation. don't want linked other side of many many relationship, thinking of making nullable (with no surprises) can't primary key it. there workaround null 1 side of many- many relation?

here sql source:

    create table [dbo].[connectionpointroutes] ( [connectionpointid] int not null, [routeid]           int not null, [segmentid]         int not null, [position]          int not null, constraint [pk_dbo.connectionpointroutes] primary key clustered ([connectionpointid] asc, [routeid] asc, [segmentid] asc), constraint [fk_dbo.connectionpointroutes_dbo.connectionpoints_connectionpointid] foreign key ([connectionpointid]) references [dbo].[connectionpoints] ([connectionpointid]) on delete cascade, constraint [fk_dbo.connectionpointroutes_dbo.routes_routeid] foreign key ([routeid]) references [dbo].[routes] ([routeid]) on delete cascade, constraint [fk_dbo.connectionpointroutes_dbo.segments_segmentid] foreign key ([segmentid]) references [dbo].[segments] ([segmentid]) on delete cascade ); go create nonclustered index [ix_connectionpointid]     on [dbo].[connectionpointroutes]([connectionpointid] asc); go create nonclustered index [ix_routeid]     on [dbo].[connectionpointroutes]([routeid] asc); go create nonclustered index [ix_segmentid]     on [dbo].[connectionpointroutes]([segmentid] asc); 

and model, notice made nullable database still puts down not nullable item

namespace inbuildingnavigator.data.models {     public class connectionpointroute     {         public int connectionpointid { get; set; }         public int? routeid { get; set; }         public int? segmentid { get; set; }         public  int position { get; set; }         public connectionpoint connectionpoint { get; set; }         public route route { get; set; }         public segment segment { get; set; }     } } 

any thoughts on workarounds problem?

the problem got solved here: optional 1 many relationship

the connectionpointroute modelbuilder had :

modelbuilder.entity<connectionpointroute>()     .haskey(c => new {c.connectionpointid, c.routeid}); 

Comments

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -