Reverse Engineering Code First With MySQL - entity-framework

Can someone help me with this problem??. I want use "Reverse Engineering Code First" with entity framework used MySQL. I was installed odbc, connector .net etc but still I cant see this... I did everything in this topic (and I have this same problem): Can't use a MySQL connection for entity framework 6
but still doesnt work :(. I was record all steps what I do it.. (Sry for english): https://youtu.be/xqEgCsu7_eU

I've gotten it to work with MySql Connector 6.9.11. Its so darned difficult and fragile I'm not sure if it was ultimately a good idea. There are at least 10 things that can go wrong and suck up hours of time. Once you get it working be very careful to not change anything. Anyhow. Here's some of my notes:
WARNING use with MySQL server 5.6.39 or 5.7.19. Do NOT use MySQL server version 5.7.21 (it fails with reverse eng) Aurora seems ok.
Install "mysql-connector-net-6.9.11.msi". There seems to be a problem with newer MySQL Connector 6.10 ?? use older 6.9.11. MUST INSTALL VIA msi file. Having the local file is not enough.
Install "mysql-for-visualstudio-1.2.8.msi" or "mysql-for-visualstudio-1.2.7.msi" ? NOTE: 1.2.7 will never uninstall correctly. VS 2015 seems to require "MySQL for Visual Studio" for EF Poco to work, (Pro,Enterprise are different)
Must have "Entity Framework Power tools Beta 4" installed as a plugin to Visual Studio 2013. Its takes some effort to get it to install for 2015, 17 but it can be done.
https://visualstudiogallery.msdn.microsoft.com/72a60b14-1581-4b9b-89f2-846072eff19d
Things that can go wrong:
ISSUE 1:
you get error "One or more errors occurred while processing template 'Entity.tt'."
This ALWAYS happens the first time i use reverse engineer after restarting VS.
Simply changing the .NET assemmbly version seems to do the trick. Target .NET 4.5 (not 4.5.1) for reverse engineer.
use .net4.5 for EF. If you see exception "System.ArgumentException: Empty path name is not legal."
remember to change back to 4.5.2 or greater.
VS2015 Edit and Continue is supported for 64-bit projects that target the .NET Framework 4.5.1. (or 4.5.2)
ISSUE 2:
System.ArgumentException: The specified store provider 'MySql.Data.MySqlClient' cannot be found in the configuration, or 'MySql.Data.MySqlClient' is not valid.
This appears to be an app/web.config issue.
??? MySql.Data.MySqlClient has more than 1 entry in in app.config ?? or bindingRedirect is wrong ?? might be wrong version consistently 6.9.11 ? MySql.Data.MySqlClient
?? Install correct version 6.9.11 in GAC not just nuget ? mysql-connector-net-6.9.11.msi
ISSUE 3:
MySQL issue - "error 6003: The value for column 'IsPrimaryKey' in table 'TableDetails' is DBNull." Specified cast is not valid.
[1 Jan 2016 15:27] "Noman Khan. Run the following command on the MySQL DB and then try if this works. set global optimizer_switch='derived_merge=off'" (on the user you will use. i.e root)
ISSUE 4:
Out of memory execption. Restart VisualStudio.
ISSUE 5:
If "MySQL" option doesnt display in the "Change Data source" listbox. Install the Visual Studio MySQL Plugin
Can't use a MySQL connection for entity framework 6
NOTE:
EntityFrameworkPowerToolsBeta4 is not built for VS2015 or 17. The installer version must be modified for it to install
How to use Entity Framework Power Tools in Visual Studio 2015?
http://thedatafarm.com/data-access/installing-ef-power-tools-into-vs2015/
NOTE:
You can view the Generated SQL query by debugging/break on the object prior to deferred execution of the query.
You can Use Aliases to map to other db's
Watch out for poor pluralization rules like "Statu" to "Status"
Check out https://us.visualstudiogallery.msdn.microsoft.com/ee4fcff9-0c4c-4179-afd9-7a2fb90f5838/view/Discussions
This seems to be more configurable and better supported. But only works for MSSQL?

Related

The Type spatial_geometry is not qualified with a namespace or alias. Only primitive types can be used without qualification

We've got an existing solution that uses EF5 and DevArt's dotConnect for PostgreSQL to connect to a PostgreSQL 9.4 database, and generate the entities.
I just installed Visual Studio 2013, and the dotConnect for PostgreSQL provider, and pulled the repository. My colleagues have the same setup, which works on their machines.
When I tried to make a build, I got the error message described in the title. I have to open the .edmx file in XML view (because VS can't show the diagram since it contains errors), and every line containing spatial_geometry as type has blue squiggly lines:
When I remove the offending lines, the project builds, but then I'm missing the spatial geometry properties, which are kinda essential to the application. I can even regenerate the entities from the database, but then I get errors that the name is not valid for each of those same properties, and the properties are then simply missing.
Why does Visual Studio complain about that spatial_geometry type (and why does it do so on my machine but not on others')? Where does the conversion between spatial_geomerty and System.Data.Spatial.DbGeometry take place?
Try upgrading to the newest (7.11.1190) build of dotConnect for PostgreSQL. Does this fix the issue? If you do not have access to the licensed v7.11.1190, please check the same with a trial.

How do I change an entity framework project to use Microsoft SQL Server

I am trying to debug a program using Entity Framework code first on my personal (work) computer.
We have recently had a domain migration, meaning that the user I log in as now is not the same that I used before. This caused me to loose access to the databases I had on the computer. To get around this, I have uninstalled everything to do with Microsoft SQL Server on the computer, and installed the latest version of Microsoft SQL Server, 2014 - 12.0.4213.0 . I then restored the database I need.
When I first tried to run the program, Visual Studio complained that the project is set up to use SQL Server Express, which was not installed. The recommended solution is to change the project to use SQL Server instead. To do this, I must click on "the database file" and follow the instructions. I have looked through the entire solution. There is a great many files, but I found no good candidate for "the database file."
It seems that my Google fu is not strong enough to find anything about this. So my question is: how do I change the project to use SQL Server?
I also have a second, related question. I tried to solve the problem by installing SQL Server Express. However, when I try to restore the database to this, no base appears in the drop down list. When I try to run the program now, I get another error:
Unable to create the file 'c:\Program Files\Microsoft SQL Server\MSSQL11.SQLEXPRESS\MSSQL\DATA\Timelønsblanket.mdf' because it already exists.
I guess that this is also why I cannot restore the database. What I have found in websearches warns that I should not manually delete .mdf files.
Any advice on what to do?
I have solved the problem. All that was needed was a correct connection string. No need to find a "database file".

Cannot remove reference to EF version 6 in build

I am using TFS 2010 and VS 2012.
I failed in my attempt to upgrade MVC4 to MVC5. I thought I rolled back my project OK in TFS but my builds fail because the references to EF version 6 have not all been removed.
As far as I can tell I have removed EF v6 everywhere in my code. However in my build I have the following message;
Unified primary reference "EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089".
Using this version instead of original version "4.4.0.0" in "C:\Builds\3\solutionA\solutionA- Test\Sources\projectB\projectB\bin\Debug\projectB.dll" because AutoUnify is 'true'.
Resolved file path is "C:\Builds\3\solutionA\solutionA - Test\Sources\MVC4\solutionA\solutionA.Model\lib\EntityFramework.dll".
Reference found at search path location "{CandidateAssemblyFiles}".
So what does "AutoUnify is true" mean?
Decided to make a proper answer from our comments. I think this initial problem was an out of sync dll, from the packages folder. You re-installed EF 5 fresh were still having packages issues.
This appears to also be something with your Nuget setup. This SO article is the same error as your latest build error. Build cannot find entity framework .
In particular this article from the accepted answer sounds very similar to the issues you're having. http://msmvps.com/blogs/rfennell/archive/2011/10/17/using-nuget-and-tfs-build-2010.aspx especially to your point that it works locally, but not in the build process. Let me know if your issues seems different.

Error when Reverse Engineer Code First with EF Power Tools Beta 2 and VS2012 Update 1

Just trying to generate POCO objects, context etc for an existing database by using the EF Power Tools Beta 2 "Reverse Engineer Code First" facility.
I'm using VS2012 Ultimate with Update 1, on Windows 7 64 bit.
I point it at my existing database and hit OK. I get the following error in my Build 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)
Any ideas?
Looks like it is a confirmed issue with Entity framework and Visual Studio 2012 update 1
The link does currently contain 2 work arounds
This is a legitimate issue on the EF Power Tools, but it's not related to the CTP issue, which was resolved in the final VS Update release. A fix for the EF Power Tools is in the works.
David Obando
Entity Framework Team
i also hit this same problem. The culprit was a package called Entity Framework Power Tool Beta 3. Updated this and everything was back to normal.

"Cannot convert lambda expression to type 'string' because it is not a delegate type" in .NET 4.5

I am trying out an existing .NET 4.0 solution in VS2012 on a test machine (that only has VS2012 and SQL Server 2008 installed), and am getting the above error when I try to use the lambda syntax with the Include extension method.
The existing version of the solution has a reference to EntityFramework.dll, which is the one I had to add to use the Include method, but the upgraded version I'm looking at in VS2012 does not have such a reference, nor can I find a DLL of that name in the location it was on the other machine. The using statement for System.Data.Entity is greyed out, as ReSharper thinks it isn't needed. Don't know why.
Sample code: This is what is in the existing solution...
using (var context = new RSSFeedsEntities()) {
WebSite someSite = context.WebSites.Include(w => w.Feeds).FirstOrDefault(w => w.WebSiteID == 1);
}
Any idea how to solve this? Thanks
Ah ha! Found the answer.
Microsoft, in their, ahem, wisdom, made the (in my opinion) blindingly stupid decision not to have Entity Framework install like other bits of the development rack, but instead made the recent versions only available as NuGet packages. Why on earth they did this is beyond me, as I now have to install EF separately for every solution, instead iof installing it cone and having it available immediately.
Anyway, I used the NuGet package manager to install EF 5.0, and the error went away.
Hope this helps someone.