“Update Model from Database” does not see a type change

后端 未结 8 1111
迷失自我
迷失自我 2020-12-10 00:54

I have several columns that I changed from Int to BigInt.

I opened up my EF model and did an \'Update Model from Database\' and expected to see those columns now be

相关标签:
8条回答
  • 2020-12-10 02:00

    I'm using VS2008 SP1. If you change the datatype in the "ModelView" (CSDL) of the edmx, errors will occur because the "DatabaseModel" (SSDL) is not updated. You have to edit the *.edmx manually (XML). That is not so hard as it sounds.

    You can simply search for the Property that the "Error List" of VS provides you (search in files is maybe the best solution for this). Go to the line where the wrong datatype appear and fix it.

    e.g. you changed float to nvarchar(50) on the database --> go to your model and change Double to String --> validate --> Error.... --> Search for the property and make following changes:

          <Property Name="YourChangedProperty" Type="float" />
    

    to

          <Property Name="YourChangedProperty" Type="nvarchar" MaxLength="50" />
    

    This works very well if you know exactly what you've changed on the database. If you've made countless changes, you would have to analyse your changes with some DB-compare tool or regenerate the whole model.

    Not very nice. But it "works".

    take care M

    0 讨论(0)
  • 2020-12-10 02:00

    Correct - data types don't appear to update automatically. You can simply change the data type in the model view using the Properties window and change the Type to Int64.

    0 讨论(0)
提交回复
热议问题