I have created an entity data model and generated a database from it.
One of the entities is called Template
.
Created partial classes to extend the functionality of Template
works fine.
If I create a new class and try to derive from Template
, I get a runtime exception upon instantiating:
Mapping and metadata information could not be found for EntityType 'Template001'
.
How can I work around this? I definitely need to inherit from the EF classes.
EDIT
Does not seem possible. If that is the case, what would be the best way to implement the following requirement: The template entity stores information about templates that each have their own code to execute. That is why I was trying to derive from the entity in the first place.
context.Template1s.Load()
vs.context.Template2s.Load()
, when all the database has isTemplate
? Could you give an example of how you intend to use this? – Wahoocontext.Template1s.Load
will never need to be called.Template1.DoWork()
will be called ifTemplate.ClassName == "Template1"
. So the entity itself knows the difference betweenTemplate1
andTemplate2
. – SteinbokTemplate1
, right? How are you going to get it? EF will instantiateTemplate
classes, because that's all the information you provided to EF. I agree with the suggestion to use the method in Sergey Sirotkin's comment. – Wahoo