dotnet / ef6

This is the codebase for Entity Framework 6 (previously maintained at https://entityframework.codeplex.com). Entity Framework Core is maintained at https://github.com/dotnet/efcore.
https://docs.microsoft.com/ef/ef6
MIT License
1.42k stars 539 forks source link

EF 6.2 tooling in VS 15.7 breaks SQLite EDMX generation #535

Closed ErikEJ closed 5 years ago

ErikEJ commented 6 years ago

2 of my users have seen issues with 15.7 - am I correct that the 15.7 release finally contains the EF 6.2 tooling?

See detailed repro steps here: https://github.com/ErikEJ/SqlCeToolbox/issues/710

Further technical details

EF version: EF 6 Database Provider: SQLite IDE: Visual Studio 2017 15.7

divega commented 6 years ago

Yes @ErickEJ, that is correct.

divega commented 6 years ago

@lajones, @ajcvickers it seems that the call to GetProviderInvarianName:

https://github.com/aspnet/EntityFramework6/blob/22a11d132306c257435fa7d6d75a31359cbbd05a/src/EFTools/EntityDesignerVersioningFacade/ReverseEngineerDb/SchemaDiscovery/EntityStoreSchemaGeneratorDatabaseSchemaLoader.cs#L41-L50

Which we introduced as part of one of the improvements, throws for SQL CESQLite, at least in some cases. Perhaps this is due to the provider being configured for the application but not for VS or machine.config?

ErikEJ commented 6 years ago

It is for SQLite, have not tested with SQL CE, but I will

divega commented 6 years ago

Thanks for clarifying. My brain’s lookup tables contain some stale entries :smile:

Perhaps the connection.GetProviderInvarianName() extension method operates on EF configuration. I think we have another version of the method on DbPrividerFactoy. Not sure if it has the same issue.

ErikEJ commented 6 years ago

Just tested with SQLCE, and it is working

ajcvickers commented 6 years ago

Assigning this to @lajones. I think we can be more defensive in calling connection.GetProviderInvarianName() and if it throws, then assume that it's not SQL Server. We may want to do a 6.2.1 patch for this.

ErikEJ commented 6 years ago

Any suggestions for workarounds?

lajones commented 6 years ago

Agreed on the defensive calling. But for now it looks as though it's having problems with reading the something in the <system.data><DbProviderFactories> section of the app.config. Or maybe it's setting up it's cache incorrectly. Are the <remove> entries necessary? Can they be removed, or moved so that all <remove> entries are before all the <add> ones? I wonder if somehow removing System.Data.SQLite is affecting System.Data.SQLite.EF6 as well?

ajcvickers commented 6 years ago

Diego pointed out that this is in the designer code, which isn't in 6.2, so changing the milestone to reflect that. Once we have a fix we should ask Barry which VS branch to target with it.

@lajones Those are some valid questions, but given that we are only using this to detect SQL Server, then I think we can just swallow any exceptions since we know that SQL Server, when configured correctly, will work and anything else doesn't really matter.

lajones commented 6 years ago

@ajcvickers Agreed. My suggestions are just for what customers can try to workaround this problem before we get a fix out to swallow the exceptions. Note: I don't know if the suggestions above will work but it's worth a try.

divega commented 6 years ago

I agree that the minimal solution would be to catch and ignore the exception, because we are only trying to detect SQL Server, which is usually registered in machine.config.

If my suspicion is correct, this is happening because the SQLite provider is registered in the application's config and not available to the designer code that is running inside the VS process. Then a possible workaround would be to put the registration of the provider in machine.config or in devenv.exe.config.

ErikEJ commented 6 years ago

I tested and documented the workaround here: https://github.com/ErikEJ/SqlCeToolbox/wiki/EF6-workflow-with-SQLite-DDEX-provider

Chris-Dickerson commented 6 years ago

Erik - tried the workaround, now I cannot get past the first step of the "Entity Data Model Wizard" (click Next it just vanishes).

I tried deleting all of my existing Sqlite connections -- didn't help.

Attaching the error I was receiving before the workaround. ef-sqlite-exception.txt

ErikEJ commented 6 years ago

Sounds like you did something wrong with your machine.config modification - did you double check all the wiki instructions? Or share your machine.config file...

Chris-Dickerson commented 6 years ago

I copied machine.config.default to machine.config and the wizard still vanishes... and yes, I double-checked everything. I tested the default machine.config with and without the DbProviderFactories section... wizard still crashes. Does this dialog report crashes anywhere?

Chris-Dickerson commented 6 years ago

After deleting all existing connections, the wizard went forward one step to making a connection, but the Connection Properties for Sqlite Provider contains only Misc -> ConnectionString... the Test Connection button works, but if you try to OK the dialog, you get:


Microsoft Visual Studio

Unable to find the requested .Net Framework Data Provider. It may not be installed.

OK

ErikEJ commented 6 years ago

The SQLite provider is not properly installed, check if the SQLite provider is in GAC, as described in the wiki article

Chris-Dickerson commented 6 years ago

You are correct, I looked at your about and it says it's not in the GAC... not sure how that happened, but I reinstalled and it's there now.

Although, when I add your suggested workaround into the machine.config, it blows Visual Studio up. If I click past this error, the theme never loads (Dark) and Visual Studio thinks it's not registered... but, if copy the default machine.config back and then run Visual Studio... everything is fine.

The error: `--------------------------- Microsoft Visual Studio

The 'CreateLayoutWizardPackage' package did not load correctly.

The problem may have been caused by a configuration change or by the installation of another extension. You can get more information by examining the file 'C:\Users\chris.dickerson\AppData\Roaming\Microsoft\VisualStudio\15.0_22f7eb32\ActivityLog.xml'. Restarting Visual Studio could help resolve this issue.

Continue to show this error message?`

ErikEJ commented 6 years ago

If you do not share your modified machine.config, it is impossible for me to give you any advice

Chris-Dickerson commented 6 years ago

machine.config.txt

ErikEJ commented 6 years ago

@Chris-Dickerson Did you read the wiki article? " You can add the following entry" - meaning both sqlite machine.config entries must be present, the first one will be added by the SQLite Tools installation? Did you install them?

Chris-Dickerson commented 6 years ago

Yes I installed the tools. (sqlite-netFx46-setup-bundle-x86-2015-1.0.108.0.exe)

ErikEJ commented 6 years ago

Then something went wrong during install, or you gave me the wrong machine.config file

Chris-Dickerson commented 6 years ago

I have everything as described by your page, I can generate the framework. The app.config configuration on your instruction page doesn't work for me, I receive an error. But If I put it back to the way I had it previously, it works.

What makes it work is adding back:

provider: <provider invariantName="System.Data.SQLite" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />

And to the factories: <add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".NET Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" />

ErikEJ commented 6 years ago

Feel free to share an app.config file that works for you, and I will try it out

Chris-Dickerson commented 6 years ago

App.config.txt

epigramx commented 6 years ago

There is indeed some peculiar uninstallation of the provider out of nowhere (I had installed it minutes before and I had confirmed with the about window that it was installed so there was no way it was not installed).

ajcvickers commented 6 years ago

@ErikEJ Just want to say thanks for all your work on helping people with this!

ErikEJ commented 6 years ago

@ajcvickers You are welcome, I brought it on myself by adding the DDEX provider to VS 2017 😢

dcppat commented 6 years ago

I'm using VS.NET Enterprise 15.7.2 and I tried to follow all the steps described for the workaround. Unfortunately I'm still experiencing the same issue.

Also, I've seen that 3.24 has been release, but the setups for .NET Framework 4.6 are still the same.

ErikEJ commented 6 years ago

If you can share a project and your machine.config, I can have a look

dcppat commented 6 years ago

Erik,

Please, find attached a basic WPF project containing the specific package references and as well the machine.config file WpfApp2017324.zip

Thank you in advance

lajones commented 6 years ago

Fix will appear in internal VS builds tonight. Will be publicly available in 15.8 Preview 4. (Solution was just to swallow the exceptions - so that if GetProviderInvariantName() fails it will be treated the same as if it was not SQL Server.)

ErikEJ commented 6 years ago

@dcppat I am also not able to make your project work, you will have to wait for VS 2017 15.8 preview 4 or generate the code in VS 2015

dcppat commented 6 years ago

@lajones and @ErikEJ,

Thank you for your help. Tell me, please, do we know what would be the official release date?

lajones commented 6 years ago

@dcppat Sorry, we aren't able to publicly announce the date. But I'll post back here when it's available.

lajones commented 6 years ago

@dcppat 15.8 Preview 4 is now publicly available.

krunalc commented 5 years ago

@ErikEJ Have you (or any one else) have tried 15.8 preview 4 version and verify that this issue has finally been resolved?

bgvsan commented 5 years ago

i have installed the 15.8.5 preview, still not able to produce an edmx

rserit commented 5 years ago

@bgvsan I'm using Dapper with SQLite. It took a lot of time with EF.

ErikEJ commented 5 years ago

@bgvsan What error do you get?

bgvsan commented 5 years ago

opening the edmx

schermata 2018-07-30 alle 13 34 17
ErikEJ commented 5 years ago

@lajones Are you able to verify the fix?

divega commented 5 years ago

@bgvsan can you please describe the exact repro steps to get this dialog? We suspect we could be looking at a different bug, or even some side effect of the workaround.

In the original bug report there was a different messages and a stack trace in the output window. Can you please compare what you are seeing with https://github.com/ErikEJ/SqlCeToolbox/issues/710#issue-322025452?

bgvsan commented 5 years ago

ok I created a new project and seems edmx working with vs 15.8.5 preview, probably there is something into my old project I have to figure out.

bruceburge commented 5 years ago

Is there an ETA on when the this code fix present in 15.8.5 will be rolled out as a stable update?

ErikEJ commented 5 years ago

Around .NET Conf maybe?

dalabe commented 5 years ago

@ErikEJ I receive an old project in EF 5.0 and I am using VS 15.8.2; I try to upgrade the EF but fails, and I keep failing, any suggestion?

ErikEJ commented 5 years ago

@dalabe Please post an issue with actionable repro steps and error messages / stack dumps