tags:

views:

29

answers:

1

Like you can see on the image

http://i51.tinypic.com/xoe14j.jpg

I have an Folder Server with the VDB.Data Class Library. In that class library i have my VDB edmx. But i wonna have my generated entities in een other folder. They must come in the Common Folder under the VDB.Common.Model --> Entities --> Generated

In the edmx are Customer ,Order , Orderdetails Then must under the generated file be a VDBEntities.tt with underneath the following entities Customer, Order, Orderdetails

But how must i do that? I only can do it under the VDB.Data Library Anybody who can help me?

A: 

You can't and don't want to put the entities in separate files. You should not modify the generated files.

All of the entities are implemented as partial classes by the framework. This means that you can extend the code in a separate file.

For example, if you want to add a calculated property to the Customer class, create a Customer.cs file in the folder of your choosing, and declare it with the partial keyword:

public partial class Customer
{
    public int CalculatedTotalOrders
    {
        get { return this.Orders.Sum(o => o.Total); }
    }
}

Although you've only declared one property in this file, you can access any of the properties of the class; the declaration is just split among multiple files -- in this case one generated file (that you don't touch) and one file of your making.

Jay
I have seen some code where the entities are in separate folders and in separate files. There is an map Entities/Generated wit the ...Entities.tt with there under the Generated Entitites. And a map Entities/General with all partial classes , like you said. But i don't know how they did that.
SvenVdb
@SvenVdb Are you sure they were just using Entity Framework, and not custom T4 templates? .tt files are T4 templates.
Jay
It could be that they use T4 Templates. I don't know. That's why i ask it here. :) Do you know how T4 Templates work? How can i set this up.
SvenVdb
@SvenVdb Here is a link to get you started: http://blogs.msdn.com/b/efdesign/archive/2009/01/22/customizing-entity-classes-with-t4.aspx
Jay
They say to click on the following item “Add New Artifact Generation Item…” in the edmx. But i have only the normal "Add Code Generation Item" :s
SvenVdb