views:

28

answers:

1

I am attempting to add a new EF4 POCO to an existing solution. I am getting following error, and when I look at existing POCO already created in the solution I cannot work out how the link is made between the POCO and the table.

Mapping and metadata information could not be found for EntityType 'XXX.Run'.

Here is an example of one that works in the solution and I cant figure out why:

namespace XXX.AnotherPlace.Products
{
    public partial class Product : BaseEntity
    {

When I look at the edmx file there is no mension of this class, just other classes in namespace that don't seem to exist:

<EntitySet Name="Product" EntityType="XXX.Store.tbl_Product" store:Type="Tables" Schema="dbo" />  

<End Type="XXXX.Data.Product" Role="Product" Multiplicity="1" />

What am I missing, there there some convenstion that need to be followed? How do I link a table with my own POCO

A: 

Your entity needs to exists within the edmx. The conventional approach is to produce the entity within the EF design surface then use the T4 POCO template to produce your classes. Assuming the solution used the templates you can add the entity to the design surface then rerun the custom tool from the property page for the T4 generated code.

Daz Lewis
I have to use t4 templates? There is no way to hand craft the class, and update the edmx from the database, and then link\map the class with the edmx entity?
Beth
No you don't have to use it. The template is just a code gen tool. As long as your poco exists within the edmx as an entity and the underlying db schema is correct it should all work.
Daz Lewis
Yeah so this gets back to my question. How do I link\relate the Entity 'shape' on the edmx design surface to the POCO that I have hand written? Does it just match on names?
Beth