Feb 27, 2012 at 4:17 PM


While looking with a great interest the differents needs i could satisfy using this library, i ran into some runtime error during the "Set_Created" method call in this particular case :

/*sample POCO model class*/
public class WorkBench
    public string Tag { get; set; }
    public string Label { get; set; }
/* ... */
/*sample insert method*/
private void InitDataContext()
    using (Context ctx = new Context())
    using(DbContextAdapter adpt = new DbContextAdapter(ctx))
        IRepository<Workbench> repo =
            new AuditableRepository<Workbench>(
                    new Repository<Workbench>(adpt)

        repo.Insert(new Workbench() { Label = "to create", Tag = "TSTc" });
        repo.Insert(new Workbench() { Label = "to update", Tag = "TSTu" });
        repo.Insert(new Workbench() { Label = "to delete", Tag = "TSTd" });


=> at "repo.Insert(new Workbench()" : System.InvalidProgramException ; stackTrace : "XXX.Workbench.set_CreatedBy(String value)", "EntityFramework.Patterns.Decorators.AuditableRepository`1.Insert(T entity)"

This workaround do the trick :

/*sample POCO model class*/
public class WorkBench : IAuditable
    public string Tag { get; set; }
    public string Label { get; set; }

    public DateTime Created { get; set; }
    public string CreatedBy { get; set; }
    public DateTime? Updated { get; set; }
    public string UpdatedBy { get; set; }

What is the proper way to decorate a model class with Archivable and Auditable attributes ?


Feb 28, 2012 at 9:43 PM

Hello GrgRz,

Thanks for using EntityFramework.Patterns.

let me ask you which version of the lib you're using?

The current stable version is 0.5 and should work in your scenario.

But if you're using the latest source code (Source code tab), then this is a known issue, that I'm trying to fix right now before releasing 0.6 version.

Anyway, your workaround is exactly what i would suggest to use, until the next release.

I hope this will help you.

Feb 29, 2012 at 4:06 PM

Hello Fab_Michellonet,

thanks for the quick reply.

I used nuget to add the needed references :

<?xml version="1.0" encoding="utf-8"?>
  <package id="EntityFramework" version="4.3.0" />
  <package id="EntityFramework.Patterns" version="0.5" />

Complete v numbers are :

  • EntityFramework.dll :
  • EntityFramework.Patterns.dll :
  • Afterthought.dll :

In order to try to understand who it works, i tried to create the needed "plumbing" classes in my model project "Project.Model", by looking at the source code and imitating the logic you've build up, in order to create my own amender :

  • Project.Model.Extensions.AmendAttribute
  • Project.Model.Extensions.IConcurrencyAware
  • Project.Model.Extensions.ConcurrencyAwareAttribute
  • Project.Model.Amenders.ConcurrencyAwareAmender<T>

The first thing i've noticed is that it seems i'm not having the same "Afterthought" version than the one used by EntityFramework.Patterns : mine doesn't implement this signature :

namespace Project.Model.Amenders
    public class ConcurrencyAwareAmender<T> : Amendment<T, T>
        public ConcurrencyAwareAmender()
            //Implement<IConcurrencyAware>(explicitImplementation: false);

I've just passed a couple of hours on it, but i failed to make it work (i've decorated the "Project.Model" assembly with the proper 
[assembly: Project.Model.Extensions.Amend] call).
Anyway i've noticed that you was quite active on Afterthought project too and saw that you recently added the Implement<T> ctor signature i was missing.

I'll keep to track those two projects, waiting for the next releases.
Thanks for your time.

Mar 1, 2012 at 10:50 PM

Hi GrgRz,

I used to test EFPatterns 0.5 against Entity Framework 4.1; i thought that it would be functional with the 4.3 version but you're proving here that this is not the case.

EFPatterns 0.6 (next version) is meant to work properly with Entity Framework 4.3.

Concerning Afterthought, the Nuget version of the lib is old and desynchronized with the github repository.

As I'm not the maintainer of Afterthought I've proposed 3 patches (including Interface implementation as you've noted)  and I'm waiting for the pull request to be hopefully accepted. In the meantime, my only option is to ship my own version of Afterthought.

I really hope to ship EFPattern 0.6 really soon... thanks for your patience.

Mar 7, 2012 at 11:48 PM

Hi GrgRz,

i've just uploaded the 0.6 version, and it should correct your two issues.


Mar 22, 2012 at 1:43 PM

Hi Fabrice,

I just noticed today the new 0.6 version on nuget. Thanks for the quick fix, i plan to update my test project this Friday.