J0NNY ZER0
J0NNY ZER0

Reputation: 707

MVC3 - Extending a Class and Updating the SQL Table

I am using MVC3 and Entity Framework. I have a class called User with 20 different properties. I have already created a database and filled it with some data. I want to break out the Addresses property and make it it's own class.

namespace NameSpace.Domain.Entities
{
public class User
{
    public int UserId { get; set; }
    ...
    ...
    public string AddressOne { get; set; }
    public string AddressTwo { get; set; }
 }
}

I want to break out both Addresses like so

namespace NameSpace.Domain.Entities
{
public class User
{
    public int UserId { get; set; }
    ...
    ...
    public Addresses Addresses { get; set; }
 }
public class Addresses
{
    public string AddressOne { get; set; }
    public string AddressTwo { get; set; }
 }
}

HERE'S MY QUESTION:

Since I already have the data table filled with data, how can I update this in the Server Explorer?

Thanks ( if you need more info please let me know )

Upvotes: 1

Views: 150

Answers (1)

Per Kastman
Per Kastman

Reputation: 4504

If you are using EF code first 4.3 you can use the concept of migrations to achive what you want.

You will need to do a code based manual migration since you change is a bit to advanced for the framework to figure it out itselfe.

Further reading: http://blogs.msdn.com/b/adonet/archive/2012/02/09/ef-4-3-code-based-migrations-walkthrough.aspx

Upvotes: 1

Related Questions