1

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!

1 Answer 1

5

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;}
    }
}
Sign up to request clarification or add additional context in comments.

Comments

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.