EF 5.x DbContext Fluent Generator for C#


A project item to generate Entities, DbContext and Fluent mapping classes. Use this template when working with an EF 5.x release.

(3) Review
Visual Studio
Download (18,717)
E-mail Twitter del.icio.us Digg Facebook
Add to favorites
Reviews (3)
Q and A (25)
Sign in to write a review
Sort by:

by Scott_Scott_Scott | January 09 2014

Just what I needed. Allowed me to use DB first and get EF 5 working with an existing stored procedure call accessed via Imported Function. Out of the box this would result in a type mismatch error when returning from the ExectueFunction. With this and some minor changes in the template file was able to get running properly.

by Levi E | November 01 2013

I was very hopeful that this would work since it would fulfill a real need, but it doesn't support complex types and throws errors when I try to run it.

by Hasibul Haque | May 14 2013

Sign in to start a discussion

  • I found a bug
    6 Posts | Last post February 26, 2014
    • Hi,
      I think I found a bug in the tool. When I create a file "MyModel.edmx" and then  using the tool by clicking "Add Code Generation Item..." the FileNotFoundException is thrown in the VS GUI. 
      {"Unable to locate file":"C:\\Users\\Mirek\\documents\\visual studio 2012\\Projects\\ClassLibrary2\\ClassLibrary2\\Model.edmx"}
      (I had to debug the Visual Studio by another VS instance to see the filename, it was not visible in the GUI directly)
      It seems it is always looking for the hardcoded file named "Model.edmx".
      Workaround: Always name your model "Model.edmx"
      Miroslav Sekera
    • Fixed. I have the new version. Thanks.
    • thanks for fixing
    • For those interested in EF6 version of this template file, i have made some changes to the original one to be able to run it under EF6. Its not perfect but it should work. I uploaded it at http://sdrv.ms/1dN6c5S
      Happy mapping!
    • @Alain Dellon Brito
      I tried out your revised template for EF6, and it worked fine until I added some enums. I.Fle's original code was casting property.TypeUsage.EdmType to PrimitiveType, but this code chokes when the property is an enum type. I added some type checking in two places to fix this.
      I posted the relevant code here. http://pastebin.com/vPzqhaEY
      This pastebin contains two separate snippets separated by an ellipsis.
    • @cbae
      I found that bug and fixed it some days before. Just didn't had time to upload a updated version. Glad you already did that. Cheers!
  • hope as soon as possible to support ef6, support vs2013
    2 Posts | Last post January 27, 2014
    • I hope as soon as possible to support ef6, support vs2013, this product is the best of all the code generator , thank you
    • hello author,your new file that Ef6FluentMapping1.tt, i feel that it like not surport mysql provider
      i use mysql connector for net,
      one function in the file report a error that meanings not recognise 'MySql.Data.MySqlClient'
      i use ef6 and mysql 5.6.15
  • EF6 Version
    1 Posts | Last post January 20, 2014
    • For those interested in EF6 version of this template file, i have made some changes to the original one to be able to run it under EF6. Its not perfect but it should work. I uploaded it at http://sdrv.ms/1dN6c5S
      Happy mapping!
  • Compatibility with VS2013
    2 Posts | Last post January 16, 2014
    • Hi,
      Is this extension compatible with VS2013? I was using it in VS2012, upgraded my solution to 2013 and now I'm unable to find the template, either installed or online,  when I click 'Add Code Generation Item' from the designer surface. I've tried installing the .vsix file and it says that 'the extension has already been applied to all compatible products'.
      Any assistance would be appreciated.
    • Follow-up: I modified the manifest so that it would install in to VS 2013 and replaced $(DevEnvDir) with C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\ as suggested by Silvestri Diego but I've getting the errors detailed below. Has anyone managed to get this working correcting in VS 2013 (with EF 6)? Any help would be greatly appreciated.
      Running transformation: System.Exception: Cannot load a metadata from the file XXX.edmx
      Running transformation: The provider did not return a ProviderManifest instance. Could not determine storage version; a valid storage connection or a version hint is required.	
  • EF6 version
    1 Posts | Last post November 13, 2013
    • Hi,
      do you have plans for a EF6 version?
  • after update vs2012, the mapping report erorr
    1 Posts | Last post November 10, 2013
    • This situation also happened in vs2013
      when create a edmx file(model file) and select 'add generate items' ,then you select this product,This error will appear:"running conversion error: no for EntityContainer Model1Container EntitySet and AssociationSet instances specified in the mapping."
  • Visual Studio 2013
    2 Posts | Last post November 01, 2013
    • I'm trying to use EF DbContext Fluent 5.x Generator for C # in Visual Studio 2013 a sample console application project but I'm not be Able to work with it.
      I get this error
      Compiling transformation: Topic instance: can not convert from 'System.Data.Metadata.Edm.StoreItemCollection' to 'System.Data.Entity.Core.Metadata.Edm.ItemCollection' cXXXX \ Model1.Mapping.tt 310 26 ConsoleApplication2
      Do you have Any idea? 
      Best Regards
    • I solved it by changing the path of Microsoft.Data.Entity.Design.DatabaseGeneration.dll in model.tt from
      $(DevEnvDir) toC:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\
  • Generation Errors with Foreign Keys
    1 Posts | Last post September 10, 2013
    • I have found that this generator is missing the mapping of a One To Many, where there is no inverse collection. Was was getting column not found MyProperty_Key. (Key is the PK of the related entity). I had to add a mapping like this:
      this.HasOptional(t => t.MyCollectionOrReference).WithMany().HasForeignKey(d => d.MyForeignKeyProperty)
      I think this needs to be added to the code generation... otherwise the mappings created by this tool are not usable unless you are exactally following the ForeignKey naming convention.
  • Errors using mappings
    1 Posts | Last post September 04, 2013
    • I am getting the following errors when querying against my model:
      Invalid column name 'RetainedEarningsAccount_Key'.
      Invalid column name 'PLSummaryAccount_Key'.
      Those are not even property names in my model class. It seems like the fluent generator is setting something to override some configuration default, but I have no idea what that could be. 
      Does anyone have any ideas?
  • Error when mapping TPH
    2 Posts | Last post August 29, 2013
    • I am getting the following error running the tool on a model that has a TPH inheritence mapped:
      Error	8	Running transformation: System.NullReferenceException: Object reference not set to an instance of an object.
         at Microsoft.VisualStudio.TextTemplatingF57CE23A0768E2A7B5E7D95FF29134F0B0197E50FF39F824E5B72D1480D777076FEA484BA645024FF81FFAFBC80B58C979072212B9706D02A2A4D5EC53A89FD2.GeneratedTextTransformation.BuildTPHMappings(XmlNode mappingNode, XmlNamespaceManager nsmgr, IEnumerable`1 entityTypes, IEnumerable`1 entitySets, IEnumerable`1 tableSets)
         at Microsoft.VisualStudio.TextTemplatingF57CE23A0768E2A7B5E7D95FF29134F0B0197E50FF39F824E5B72D1480D777076FEA484BA645024FF81FFAFBC80B58C979072212B9706D02A2A4D5EC53A89FD2.GeneratedTextTransformation.LoadMetadata(String inputFile)
         at Microsoft.VisualStudio.TextTemplatingF57CE23A0768E2A7B5E7D95FF29134F0B0197E50FF39F824E5B72D1480D777076FEA484BA645024FF81FFAFBC80B58C979072212B9706D02A2A4D5EC53A89FD2.GeneratedTextTransformation.TransformText()	
      I can provide the edmx if that will help.
    • ok, I think I see what's going on here. My EDMX has a TPH relationship where the subclass is discriminated with a Is Not Null and the parent class with Is Null. My code change below got rid of the error, but the mapping isn't correct. How would you map HasValue(not null) ??? Is that even possible? 
1 - 10 of 25 Items