entity framework not working on table without identity column

前端 未结 2 937
太阳男子
太阳男子 2020-12-19 07:14

I have the following table:

create table tbl
(
    id int identity(1,1),
    val varchar(100)
)

Now when i use Entity Framework to map obje

2条回答
  •  误落风尘
    2020-12-19 08:14

    Entity frameworks generally need a way to distinguish between two records in a table and so require a ID/Key discriminator which need not be a primary key constraint or a unique key constraint or an identity at the DB layer. But this discriminator, a column or a set of columns, should help the entity framework identify a record uniquely and distinguish it from other records. So, you need to define such a discriminator in your entity class at the C# layer.

提交回复
热议问题