问题
I already have a table with a varchar Primary Key. This is working fine with my current .edmx.
Now I added an auto-increament identity column in that table. While I try to update the .edmx, that table is not being included in .edmx
Can't I put a varchar PK column and an auto-increament identity column in the same table?
回答1:
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
回答2:
It should not be the problem. Save your database table with the new column, delete and recreate .edmx. Hope it'll be done.
来源:https://stackoverflow.com/questions/47015070/create-entity-with-both-primary-key-and-identity-column-in-ef6