0

I use Code First Entity Framework 6.0 approach and have BaseClass and some of DerivedClasses. I used to manually update database (all tables derived from BaseClass).

I want to update (doesn't matter where) data 1 time.

Classes:

public class IItem {

    public int Id {
        get;
        set;
    }

    public string Model {
        get;
        set;
    }

    public int Cost {
        get;
        set;
    }

    //other properties

}


public class MotherBoard : IItem {

    public string Manufacturer {
        get;
        set;
    }

    public string FormFactor {
        get;
        set;
    }

    public string CPUManufacturer {
        get;
        set;
    }

    public string Socket {
        get;
        set;
    }

    public int SocketCount {
        get;
        set;
    }

    //other properties

}

//there are 3 more classes

Ef context:

public class EFDbContext : DbContext {

    public IDbSet<MotherBoard> MotherBoards {
        get;
        set;
    }


    public IDbSet<Processor> Processors {
        get;
        set;
    }


    public IDbSet<VideoCard> VideoCards {
        get;
        set;
    }


    //other

}

1 Answer 1

1

Hi could you post your code for your classes and context class?

What versions are you using of EF and in what context?

Do you have just the one context? If so try in PowerShell whilst targeting the project with your context

enable-migrations
add-migration Initial
update-database

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks tuppers for reply. I have added what you asked.
no worries hope you get it sorted - try looking at stuff from Julie Lerman excellent tutorials etc

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.