I have an asp.net mvc 2 application with a SQL Server database accessed by the Entity Framework ORM. Now I found out I had used the wrong datatype for one of the fields in the database – int instead of double.
Now, this is not a big commercial application, but it is nevertheless already in use internally in my company. It works fine, but the users would need to be able to enter decimal values rather than just integers…
So my question is, can I change the type of the field after the fact so to speak, and not lose the data already entered? Of course I would have to change the references to this field in the model and everything that references it, but is it possible at all without losing the data?
I would appreciate any suggestions for how to go about solving this problem!
Well if you used int instead of decimal the data you have might have already been incorrect and code would even break. You wont lose any data in your case as you are going from int to decimal.Steps you need to take-
You might want to do the database step last in case your stuff is live and being used in that case do it when you upload the changes.