Preview of useful design-time features for DbContext.
When right-clicking on a C# project, the following context menu function is supported:
1) Reverse Engineer Code First - Generates POCO classes, derived DbContext and Code First mapping for an existing database.
Unable to view entity data in any format from 'Entity Framework' submenu in Solution Explorer. Exception thrown in dialog box: "Exception has been thrown by the target of an invocation" when I attempt.
Reverse Engineering DB works, however. Great feature!
This was working excellently for me but recently I have been getting the error below when doing a reverse engineer. I have been pulling my hair out trying to work out what's going wrong. The same solution works on my coworkers machines when doing the same thing so it must be something wrong on my Visual Studio.
One or more errors occurred while processing template 'Entity.tt'. CodeTemplates\ReverseEngineerCodeFirst\Entity.tt(2,4) : error : There was an error loading the include file 'EF.Utility.CS.ttinclude'. The transformation will not be run. The following Exception was thrown: System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.DbContextPackage.Utilities.EfTextTemplateHost.Microsoft.VisualStudio.TextTemplating.ITextTemplatingEngineHost.LoadIncludeText(String requestFileName, String& content, String& location) at Microsoft.VisualStudio.TextTemplating.Engine.ProcessIncludeDirective(Directive directive, ITextTemplatingEngineHost host)
I'm having trouble reverse enginering a database named [133.0040] (without the brackets) resulting in:
System.ArgumentException: The modelEntityContainerName parameter '1330040Context' contains characters that are not valid. at System.Data.Entity.Design.EntityModelSchemaGenerator.Initialize(EntityContainer storeEntityContainer, IEnumerable`1
storeFunctions, String namespaceName, String modelEntityContainerName) at System.Data.Entity.Design.EntityModelSchemaGenerator..ctor(EntityContainer storeEntityContainer, String namespaceName,
String modelEntityContainerName) at Microsoft.DbContextPackage.Handlers.ReverseEngineerCodeFirstHandler.ReverseEngineerCodeFirst(Project project)
Please advise (renaming the database is not an option).
Hello! When I try to execute this action *Right-click on the CodeFirstExistingDatabaseSample project in Solution Explorer *Select Entity Framework -> Reverse Engineer Code First
from http://msdn.microsoft.com/en-us/data/jj200620 lesson I see this message in Output window: One or more errors occurred while processing template 'Entity.tt'. C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\Extensions\Microsoft\Entity Framework Tools\Templates\Includes\EF.Utility.CS.ttinclude(1,4) : error : A processor named 'T4VSHost' could not be found for the directive named 'CleanupBehavior'. The transformation will not be run. The following Exception was thrown: System.InvalidOperationException: Cannot find processor for directive 'T4VSHost'. at Microsoft.DbContextPackage.Utilities.EfTextTemplateHost.Microsoft.VisualStudio.TextTemplating.ITextTemplatingEngineHost.ResolveDirectiveProcessor(String processorName) at Microsoft.VisualStudio.TextTemplating.Engine.ProcessCustomDirectives(ITextTemplatingEngineHost host, TemplateProcessingSession session, IEnumerable`1 directivesToBeProcessed)
Good in theory, they need to fix their release process. It's been several weeks since the tools became inoperative with VS2012 and nobody has bothered releasing an update. How are you supposed to depend on the tools in a commercial environment with such response times? Luckily James Manning has a work-around (that works for us) but as a MSFT EF product, this should have been fixed on the order of hours, not weeks (and it's a simple fix too!).
HI Guys, tried using against latest MySql.Entities available through NuGet but fails on the Mapping.tt file.
To resolve issue I produced the tt. CodeTemplates from the content menu (right click) then commented out the sections in the mapping.tt file for the FixedLength & MaxLength checking. For some reason on MySql these pieces of information are missing in the properties retrieved from when the database schema is read. If these following properties could be populated then the tool would work fine for MySQL as well, as it is, i can at least generate all the entities as it is then just go through and apply the StringLength value (or MaxLength) to the relevant fields which is most string (varchar) fields :)
var fixedLengthFacet = (Facet)prop.TypeUsage.Facets.SingleOrDefault(f => f.Name == "FixedLength"); var maxLengthFacet = (Facet)prop.TypeUsage.Facets.SingleOrDefault(f => f.Name == "MaxLength");
Great tool, couple bugs and suggestions to report (albeit fairly minor). I'm using version 0.6.0.0. 1.Bug- Reverse engineering fails if 'save password' not checked on database connection dialog. 2.Suggestion- Can you store the most recently used server names in the drop drop down of the database connection dialog? 3.Suggestion- When reverse engineering is in progress, there is no UI indication that work is occurring and behaves as if it is frozen (VS 2012). 4.Bug/Suggestion. When you right click on the project to get the Entity Framework menu, accidentally clicking on 'Customize Reverse Engineering Templates' overwrites any existing customized templates with no confirmation dialog box. If the templates already exist in your project, you should at least get a warning that they will be overwritten. 5. Suggestion- Any way to change the output directories for the generated code?
I love using this tool, just hope it gets continued attention and refinement.
I was able to add support for WCF Soap serialization in the Entity.tt file by adding 'using System.Runtime.Serialization' and attributes [DataContract(IsReference=true)] for each class and [DataMember] for each property. This is the only practical way that I have found to automatically add WCF Soap Serialization support to EF5 entities. Waiting anxiously for new features that will allow for stored procedure support and for picking and choosing the objects for the model, like in the database first scenario. Thanks for this tool.
For those not wanting to install it, Rowan Miller posted a workaround for the 'T4VSHost' error on the EF blog until a new signed version of the Power tools is published: http://visualstudiogallery.msdn.microsoft.com/72a60b14-1581-4b9b-89f2-846072eff19d
I quote: "As a workaround to this issue you can edit Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\Extensions\Microsoft\Entity Framework Tools\Templates\Includes\EF.Utility.CS.ttinclude and remove the first line (<#@ CleanupBehavior Processor="T4VSHost" CleanupAfterProcessingTemplate="true" #>).
The only side effect of doing this is that the EF Designer will use more virtual memory when you create and edit models. On most computers this isn't a problem."
By the way, thanks to the EF team for this very useful extension!
I think is does not create the mapping files correctly. The varchar columns are not adding IsUnicode(false). Line 90 should be var unicodeFacet = (Facet)prop.TypeUsage.Facets.SingleOrDefault(f => f.Name == "Unicode"); not var unicodeFacet = (Facet)prop.TypeUsage.Facets.SingleOrDefault(f => f.Name == "IsUnicode");
Once I did this my select by varchar columns stopped timing out.
Here's a workaround for the below 'reverse engineer' error:
*** error : A processor named 'T4VSHost' could not be found for the directive named 'CleanupBehavior'. The transformation will not be run. The following Exception was thrown: System.InvalidOperationException: Cannot find processor for directive 'T4VSHost'. ***
I don't know the underlying cause, but rebuilding the extension from current source in the repo and installing it worked fine for me.
- install VS SDK first (the Power Tools project types includes Extensibility, so you'll need the SDK installed to load that project) - git clone the EF repo - build PowerTools.sln from repo root - uninstall existing EF Power Tools Beta 2 extension - install the vsix just built @ entityframework\src\PowerTools\bin\Debug\EFPowerTools.vsix
Hopefully the EF team can share a recent signed build and we can start using that as a workaround until the 'official' extension is updated.
If you're unable to fetch/build the extension yourself for some reason, I've shared my (unsigned) build of it via skydrive @ http://sdrv.ms/VEKzaK
I'm on Windows 7 using Visual Studio 2010. I'm writing a regular c# class library (the squiggly kind ;D ) with EF 5.0 this EFPT Beta 2 and the MYSQL data provider. I've got some feedback...
When I reverse engineer, I get the first of my MYSQL tables mapped, then it just falls over with the following:
System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.DbContextPackage.Extensions.ProjectExtensions.InstallPackage(Project project, String packageId) at Microsoft.DbContextPackage.Handlers.ReverseEngineerCodeFirstHandler.ReverseEngineerCodeFirst(Project project)
One or more errors occurred while processing template 'Mapping.tt'. error : Running transformation: System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.VisualStudio.TextTemplatingac862cc9523b4d3aa384fb08a147013b.GeneratedTextTransformation.TransformText() at Microsoft.VisualStudio.TextTemplating.TransformationRunner.RunTransformation(TemplateProcessingSession session, String source, ITextTemplatingEngineHost host, String& result)