Tomas
Tomas

Reputation: 18117

set calculated field as not nullable

I have a calculated field in MSSQL table view.

CAST((MyCalcField) AS BIT) AS UsersManager

When Entity Framework create model of this view it always set UsersManager field as nullable. Is it possible to using SQL to set field as not nullable? I know what I set set field type directly in EF model but I would like to keep field type structure in MSSQL.

Upvotes: 1

Views: 83

Answers (1)

Mikael Eriksson
Mikael Eriksson

Reputation: 138990

Try to use ISNULL

ISNULL(CAST((MyCalcField) AS BIT), 0) AS UsersManager

Upvotes: 2

Related Questions