Start a new topic

How to create a computed field ?

I'm trying move my .NET 4.5 WPF application from using SQL Server to VistaDB. Before the migration process, my app worked with EF 6.1 (code first) but since VistaDB doesn't support it, I moved to DB first approach.

Some of my entity classes, contained computed fields, for example:

public class example
{
    public int SomeNumber {get; set;}

    [NotMapped]
    public int ComputedInt
    {
        get
        {
             return SomeNumber * 3;
        }
    }
}


Since EF DB first generates it's entities automatically, I don't want to make changes inside the entities classes. I thought to create a computed fields inside VistaDB but I didn't find how to do it. Is it possible? Do you might have a better solution for this issue?


Thank You!!!

Simple and  brilliant :-)


What most folks do in this situation is add a partial class file with the extra methods.  This way you're not modifying the generated code (don't do that!) and you can add all kinds of extra stuff.  We do this ourselves where we use EF within Loupe and when we've done client projects (where we typically use the Db First approach)

Login to post a comment