Change datatype of column to uniqueidentifier from bigint

后端 未结 5 1042
遇见更好的自我
遇见更好的自我 2021-01-01 19:05

I want to change the datatype of a column in a table in sql server. I used the following statement:

ALTER TABLE dbo.tbltest  
ALTER COLUMN ID uniqueidentifie         


        
5条回答
  •  感动是毒
    2021-01-01 20:03

    Note to people using Entity Framework:
    Obviously, if you have a large database with complex relationships, dropping all relationships and ID columns, and re-adding them is a huge ordeal.

    It's much easier to update the generated model (.edmx).

    Yes, Visual Studio allows you to update the data type without complaining. In fact, when you save the .edmx file, the relationships will be validated; any fields that you may have missed will show up as errors.

    After you're finished, you can regenerate the database from the model. Boom, done.

提交回复
热议问题