Closed vancodocton closed 7 months ago
It is the problem of create view, not scaffolding tool. When I run:
select * from information_schema.columns where table_name = 'terminal';
select * from information_schema.columns where table_name = 'terminal_view';
I have result
As we can see, that view columns is_nullable
are YES
, that is not the same as of table.
Following https://stackoverflow.com/questions/17301323/why-are-my-views-columns-nullable, we have a workaround is that update attnotnull
to true
of table pg_attribute
to ensure the nullability of scaffolded view model.
UPDATE pg_attribute
SET attnotnull = true
WHERE attrelid = 'terminal_view'::regclass
@vancodocton do you think there's anything to do here on the EFCore.PG side?
@roji I think it is not necessary.
Thanks.
I scaffold view of table that select several instead of all columns of a table. However, the model of view does not persist the column nullability as SQL Server does when scaffolding.
I posted a question on SO: https://stackoverflow.com/questions/78273009/postgresql-view-column-not-null-is-not-persist-when-reverse-engineering-using-en