create entity with both primary key and identity column in EF6

笑着哭i 提交于 2019-12-05 23:54:13

Yes, here's an example. The identity property has nothing to do with the PK. It just won't ever be null, obviously, and increments from the seed based off what ever you set.

create table myTable ( VC varchar(64) not null
                        ,primary key (VC)
                        )

insert into myTable
values
('something')
,('else')


select * 
from myTable

alter table myTable
add id int identity (1,1)


insert into myTable (VC)
values
('thirdColumn')


select * 
from myTable

It should not be the problem. Save your database table with the new column, delete and recreate .edmx. Hope it'll be done.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!