Click here to Skip to main content
15,879,474 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i have several property in my class that after adding a new property and doing code first migration , the new added fields have null value in Previous records in database , does anybody have any idea about how to set value to them ???

What I have tried:

.....................................................................................
Posted
Comments
CHill60 2-Sep-18 13:23pm    
Write a sql query to update them to whatever you want the default value to be.
Member 13933681 3-Sep-18 2:49am    
they're not default values
CHill60 3-Sep-18 4:10am    
Then write a sql query to update the older records to the values you want them to be. Run that query via Sql Server Management Studio (or whatever IDE is relevent to whatever database you are using).
Personally, I strongly dislike Code First programming - in my experience, the database always ends up in a right state.
Sinisa Hajnal 5-Sep-18 2:28am    
I strongly agree with this CHill60. Write your database first and then code over that. Database is made to work with data, code is for logic and presentation.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900