Apologies made a mistake in the schema, T.B should be not nullable:
CREATE TABLE [dbo].[t](
[a] [int] IDENTITY(1,1) NOT NULL,
[b] [int] NOT NULL CONSTRAINT [DF_t_b] DEFAULT ((1)),
CONSTRAINT [PK_t] PRIMARY KEY CLUSTERED
(
[a] ASC
)
) ON [PRIMARY]
Ok, I think I understand. However looking at this from a model point of view in entity T we have 2 fields, A the identifier, and B. In entity T2 we have just the identifier and a relation to T. We want T2 generated with the field B from T so when the code for T2 is generated we get fields on T2 for the identifier field pk, the foreign key linking field fk (which from a model point of view is field A in T) and the related field B. In the code for T2 the fk (entity T's field A) is nullable and B is not nullable. I understand why based on your reply, as B maps to entity T.B which is not nullable, but it seems a bit odd. Would it be reasonable to ask in a future release that we have some checkbox on the relation which allows us to say "This relation is optional so mark all mapped related fields as optional regardless of their definition in the defining entity" ?
Maybe the reason why am I here will help my case. I have a grid where the user can create T2 entities by adding rows into the grid. This happens to be in a Telerik grid using the Silverlight controls and RIA to generate the client side entities. Mapped field B is not in the grid, reasonably as its not part of entity T2. However the client side code tracks what fields are mandatory and what are populated and before it attempts to add a new entity to the backing list, it checks that the mandatory fields are populated. It's not aware the field B is a mapped field, it just sees it as an int that has not been set and the row/entity then fails validation.
Thanks