sql server - database first change primary key from int to uniqueidentifier -
i trying change primary key in 1 of tables int uniqueidentifier. pointed out in title, taking database first approach using entity framework.
the process took remove primary key table in sql designer , renamed column "itemid" "item".
i created column named "itemid" , set uniqueidentifier type default newsequentialid().
then deleted column renamed "item" , set "itemid" primary key.
i moved visual studio , did update model database gave me error
error 1 error 2019: member mapping specified not valid. type 'edm.int32[nullable=false,defaultvalue=]' of member 'itemid' in type 'shoppingmodel.dbfruits' not compatible 'sqlserver.uniqueidentifier[nullable=false,defaultvalue=,storegeneratedpattern=identity]' of member 'itemid' in type 'shoppingmodel.store.dbfruits'.
and here model under .tt directory
public partial class dbfruits { public dbfruits() { this.dbcart = new hashset<dbcart>(); } public int itemid { get; set; } public string name { get; set; } public string price { get; set; } }
i've run similar issues before, , found way solve delete table model. save , close model. reopen model , re-add table.
Comments
Post a Comment