why does visual studio delete my classes when I update entity framework model

后端 未结 3 1500
[愿得一人]
[愿得一人] 2021-02-15 23:45

I\'m having a strange problem when I update my EF model (ver 5). It deletes all of the classes that belong to that model.

My situation was like this. I changed the key

3条回答
  •  北恋
    北恋 (楼主)
    2021-02-16 00:15

    The same thing happened to me. I had a table with a string value but I wanted to change this to a foreign key so that I could store the reoccurring string values in a separate table. So I created a new table and I changed the string column type to a not nullable int and added a foreign key. When I updated the model, it marked all entity classes as deleted... not funny.

    I also saw some errors popping up indicating that EF didn't change the column type from string to int.

    The solutions mentioned above (the custom tool and transforming all templates) did not work for me.

    For me the solution was to change the column type from string to int manually in the model first and then updating the model, no more issues occured.

    For the record: this happened in EF 4 in Visual Studio 2010.

提交回复
热议问题