Fake context object set properties

Nov 9, 2010 at 10:58 AM
Edited Nov 10, 2010 at 3:57 AM


Firtst, thanks for the effort. This seems to be a must have for every  LOB EF4 dev team.

Second, it seems that the object set properties and the backing fields fake are all generated witht he plural in the type parameter (c#).


 public interface IContext

  /// <summary>Child IObjectSet</summary>
  IObjectSet<Child> Child { get; }

if implemented as:

public partial class FakeParentChildTrialsEntities1 : IContext, IDisposable


 #region ObjectSet Properties
 private IObjectSet<Children> _Children = new FakeObjectSet<Children>();


NOTE THE 'Children' INSTEAD OF 'Child'

Maybe you should consider changing the state of the project from 'stable'.





Nov 9, 2010 at 5:37 PM


I second Asher.  

The pluralization is indeed generated.  I am new to T4 and by all means a novice.  I made a change to the T4 to fix this issue; however, the fix presented another issue.  I again fixed the new issue, and found another.  Anyway... I fixed the templates to the point where there is no compile time errors; however, the fixes are just that - fixes to prevent compile-time errors.  

Since I'm a T4 novice, I cannot guarantee the fixes will not break moving forward.  

If you are interested, the EntityGenCSharp template directory with fixes is zipped and located at the link below.  I wish CodePlex provided uploads via discussions.  

Again, great work here... I hope my changes help solve at least one or two issues  Please let me know if this works... thanks... -Dan



Nov 10, 2010 at 4:10 AM

Hi dryan,

Thanks for the fixes. I started going that path myself and decided to wait for a little while. I suggest we wait and see what rickrat has to say (I hope he is monitoring the discussion page).  I would say that the c# version has not reached the 'stable' state yet. If Rick intendes to carry the c# version forwards we probaboly better wait for him. If he would like to combine efforts that would be nice too.

We are going into development with EF4 and would definetly need generated IUnitOfWork/IContext. If this project flies we would be happy to use it and re-contribute whatever we decide to develop on top of it (including fixes of course).




Nov 16, 2010 at 7:55 AM

Hi, thanks for your feedback guys!

If it is generating plurals, it's because when you add the tables in the designer you might have the pluralize checked? if you have it unchecked does it replicate that behavior?

Can you duplicate this with the example project's code base?



Nov 17, 2010 at 1:53 PM

Hello Rick:

The issue with pluralization is the data type and not the name.  For example:

private IObjectSet<Albums> _Albums = new FakeObjectSet<Albums>();

Notice that the data type is Albums and should be Album.

As per your recommendation - pluralize checked - I set Pluralize New Objects to false on the model.

I encounter the same issues.

Thanks... -Dan

Nov 17, 2010 at 5:26 PM

Yeah, the pluralization thingy annoys me in EF4. 

With the generated code, is the data type wrong for all of the gen'd code or just certain classes?

I'm not doing anything special as far as pluralizing that I know of.


Nov 17, 2010 at 6:39 PM

Hello Rick:

The initial issue was the T4 that generated the fakes.  I fixed that issue and another issue came up.  As I mentioned in a previous post, this pattern (fix, new issue, fix) happened maybe four times - all at compile time.  The changes I made to avoid the compile time exceptions are in the zip from a previous post. Again, the fixes fix compile time exceptions.  I'm too new to T4 to confirm if the changes do or do not affect non-compile time exceptions.

Anyway, hope that helps somewhat... -Dan

BTW, been seeing a lot of press on Twitter for your templates... ;-)

Nov 18, 2010 at 5:41 AM
Edited Nov 18, 2010 at 5:53 AM

Good catch you guys! I've elevated this to a work item 7691.

This has been fixed.



Nov 18, 2010 at 3:38 PM

No problem Rick!  You did all the hard work...  BTW, I don't know if you received a notice or not, but I commented on your quick start a week or so ago.  A typo and suggested prereq.  Anyway, good stuff... -Dan

Nov 29, 2010 at 5:46 AM

Typo is fixed.