views:

313

answers:

1

Hello,

I am new to using the ADO.NET Entity Data Model tool. I have a table in my database that has three properties (FirstName, LastName, Age). I need to add a field to this entity called IsChosen. However, I cannot add this column in the database.

How do I add custom properties to entities generated through this tool?

Thank you!

+2  A: 

The Entity Data Model tool creates partial classes.

You can extend those partial classes in another source file. You just need to make sure your section of the partial class lives in the same namespace as the Entity Data Model generated classes. For example:

Tool Generated Code

namespace Your.Generated.Classes
{
    public partial class Stuff
    {
        public string Name {get; set;}
        public int Age {get; set;}
    }
}

Your Seperate Code File

namespace Your.Generated.Classes
{
    public partial class Stuff
    {
        public string NonDatabaseProperty {get; set;}
    }
}
Justin Niessner

related questions