Asked by:
Code first migration

Question
-
User-1852975005 posted
Hi, I have a ASP.NET Web Application (.NET Framework) using MVC.
I have created it following a tutorial changing code to suit my needs.I will be changing the model, adding things like phone number etc.
Can some one tell me a foolproof way of carrying these changes through to the database with code first migration please.
As I have not managed to do by following the tutorials I have found so far.Thanks,
Tuesday, March 24, 2020 9:36 PM
All replies
-
User475983607 posted
Make a change to the Entity, add a migration, then update the database. The standard tutorials on this site illustrate the concept quite clearly.
Tuesday, March 24, 2020 9:40 PM -
User1120430333 posted
IMO, an ORM is not a DBA tool. You could look into using traditional DBA tools and techniques and save yourself some grief.
Tuesday, March 24, 2020 11:52 PM -
User-1852975005 posted
IMO, an ORM is not a DBA tool. You could look into using traditional DBA tools and techniques and save yourself some grief.
Do you mean MSQL manager?
Wednesday, March 25, 2020 7:18 AM -
User1120430333 posted
I am talking about SSMS that is free.Wednesday, March 25, 2020 10:02 AM -
User-1852975005 posted
I am talking about SSMS that is free.
I concur. Building a db from the first time you run the code seems to work fine.
But when you want to make a change, nothing seems to work. Probably something I’m not doing right.
However, I cant make sense of the tutorials I have found.
So long as I add a new column to the model and match it in the table it should be good right.
Can I also use SSMS on the localDB with Visual Studio?Thanks,
Wednesday, March 25, 2020 10:11 AM -
User1120430333 posted
So long as I add a new column to the model and match it in the table it should be good right.
Your EF model should match the database table in question, meaning that you can manual configure the table for the new column using SSMS
You can use localdb with MS SQL Server Management Stuido aka SSMS. SSMS is a free download and installation of SSMS from MS that is a standalone DBA tool.
https://www.tutorialspoint.com/ms_sql_server/ms_sql_server_management_studio.htm
https://dotnetthoughts.net/connecting-localdb-using-sqlserver-management-studio/
Can I also use SSMS on the localDB with Visual Studio?You can use Server Explorer in Visual Stuido and connect to LocalDb. But Visual Stuido Server Explorer is not SSMS
Wednesday, March 25, 2020 11:03 AM -
User475983607 posted
What does "nothing seems to work" mean? Can you share your code and explain the steps to reproduce "nothing seems to work"?
Did you go through the tutorials in my first post? I went through the and modifying a Entity updates the table.
Also what version of EF are you using?
Wednesday, March 25, 2020 11:04 AM