Entity Framework And Business Objects

When you define an entity in the EDMX model you can specify the visibility of each property's setter and getter, so if you don't want the ModifiedDate to be visible in other layers, you can simply specify it as internal.

enter image description here

If your requirements are more complicated like the ModifiedDate should be accessible in the entities assembly and the business logic assembly but not in the UI assembly, then you need to create another object which will be exchanged between the business logic and the UI logic layers.


Personally use a wrapper class over entity and expose or shadow what I need.

// instead of below property in your BLL:

private int m_someVariable;

public int SomeVariable
{
    get { return m_someVariable; }
    set { m_someVariable = value; }
}

// You can use the entity object:

private readonly EntityClass _entityObject = new EntityClass();

public int SomeVariable
{
    get { return _entityObject.SomeVariable; }
    set { _entityObject.SomeVariable = value; }
}

// or make it read-only at your BLL

public int SomeVariable
{
    get { return entityObject.SomeVariable; }
    // set { entityObject.SomeVariable = value; }
}