c# - How to setting a model with table don't have any primary key column -




on setting dbcontext, have

modelbuilder.entity<person>(app => {     app.totable("person"); }); 

the efcore throws exception:

the entity type "person" requires primary key defined

but our person table doesn't have primary key column.

how avoid ?

ef core doesn't support tables without primary keys (aka heaps). reason simple: needs able manipulate individual records, cannot safely achieved without primary key. resolution, can add dummy column/primary key of type int/identity or guid/uniqueidentifier, , ignore it.





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -