I have a database already full of tables with data in them. What I have seen is that all tables have 5 columns in common:
Now, there are some common operations that are done based on those fields which currently are replicated everywhere
What I want is to create a base class containing just these common attributes and the methods done to them and make every other entity derive from this.
I don't need or want to have this base entity on the database per se, this is just something I want to help the coding part.
The issue is this is Database first, I cannot alter the database so all I have to work with are the POCO classes and the EDMX.
How can i achieve this?
What you are looking for is something similar to TPH (http://msdn.microsoft.com/en-us/data/jj618292.aspx)
I don't think this will work for you however, as you have multiple existing tables.
One of the possible solutions is:
Thanks, Dave
Done. Once you save the model you will have all your old entities deriving the base class and when a new one is generated by this template it will derive the base class as well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With