Click here to Skip to main content
14,265,748 members
Rate this:
Please Sign up or sign in to vote.
See more:

I'm developing a C# application using Entity Framework database first, since I already have an existing database which I want to analyze.

The table that I'm using has a "Target" column and a "Actual" column and I need to determine the progress, which would be Actual/Target.

Where should this data be? Should I create a new column with this formula in my database (SQL Server btw), or should I do this calculation in my code? If the latter option is the best one, then how would I change my model that was created automatically by entity framework?

What I have tried:

Creating a formula column, but don't know if it's best practice
Richard Deeming 29-May-19 14:01pm
Will you be trying to query this calculated property? (Filter, sort, etc.)

If so, then it will need to be a calculated column in the database.

If not, a custom read-only property in your C# class would work. The entities generated from your database will be in partial classes, so you can create a separate file to hold your custom code which won't be overwritten by the designer.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100