I'm planning a new site and I think i'm going to use MVC and EF 5. Now I have a question about EF and code first. Lets say I build a simple guestbook with code first and publish it to the web. People writes in my guestbook, but after two weeks I like to
store the visitors ip in my database. Then I add the ip to my class and so on, but how does this work with code first? Will everything that is in my databes get lost? If it gets lost, is there a way to do this without the data getting lost? If so, can you
point me to a tutorial?
I have search the web but I cant find a good answer.
svetsarn
Member
487 Points
612 Posts
Change database with code first?
Dec 22, 2012 03:16 PM|LINK
Hi
I'm planning a new site and I think i'm going to use MVC and EF 5. Now I have a question about EF and code first. Lets say I build a simple guestbook with code first and publish it to the web. People writes in my guestbook, but after two weeks I like to store the visitors ip in my database. Then I add the ip to my class and so on, but how does this work with code first? Will everything that is in my databes get lost? If it gets lost, is there a way to do this without the data getting lost? If so, can you point me to a tutorial?
I have search the web but I cant find a good answer.
I'm using VS 2012, .NET 4.5 and EF 5
XIII
All-Star
182674 Points
23445 Posts
ASPInsiders
Moderator
MVP
Re: Change database with code first?
Dec 22, 2012 06:07 PM|LINK
Hi,
since EF code first 4.3 you have the ability to make use of database migrations: http://blogs.msdn.com/b/adonet/archive/2012/02/09/ef-4-3-code-based-migrations-walkthrough.aspx.
It's also featured in this presentation by Scott Guthrie: http://channel9.msdn.com/Events/TechDays/TechDays-2012-Belgium/287.
Grz, Kris.
Interested in Azure, ASP.NET (MVC), jQuery, WCF, EF, MS SQL, ...
Keep the forums clean: report to the moderation team!