开发者

How does Entity Framework relate a custom POCO to a table?

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 t开发者_如何学Pythonhis 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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜