ErikEJ / EntityFramework6PowerTools

This is the codebase for Entity Framework 6 Power Tools Community Edition, and modern EF 6 providers for SQL Server and SQL Server Compact
Other
183 stars 27 forks source link

Exception When Generating Views in EF6.4.4 in VS2019 #74

Closed reactor-gonguela closed 4 years ago

reactor-gonguela commented 4 years ago

Hello, i'm getting an error when atempting to generete the views for my code first context and i don't know how to fix it. I already tried to reinstall the power tools but nothing seems to wok. Capture

ErikEJ commented 4 years ago

Please share your csproj file

reactor-gonguela commented 4 years ago

`<?xml version="1.0" encoding="utf-8"?>

Debug AnyCPU {267E7D7D-E4F5-4BAB-B88D-39EAC92FC1A3} Library Properties CrmDatabase CrmDatabase v4.7.2 512 true true full false bin\Debug\ DEBUG;TRACE prompt 4 pdbonly true bin\Release\ TRACE prompt 4 false ..\packages\EntityFramework.6.4.4\lib\net45\EntityFramework.dll ..\packages\EntityFramework.6.4.4\lib\net45\EntityFramework.SqlServer.dll False ..\..\Reactor.Framework\Reactor.Entity\bin\Debug\Reactor.Entity.Base.dll ..\..\Reactor.Framework\Reactor.Security\bin\Debug\Reactor.Security.dll This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. `
as206em commented 4 years ago

same issue here

ErikEJ commented 4 years ago

I am not able to reproduce in the latest VS 2019 version, please provide a repro project, and I will investigate.

ErikEJ commented 4 years ago

Ping ?

as206em commented 4 years ago

Hi I have windows 10 Pro version 2004 and Visual Studio Enterprise 2019 Version 16.7.5. i'm getting the following error

image 'Console.Domain' is a project in my solution and the solution is buildable and working with no issues.

and here is the csproj content for the project i'm trying to generate views for ` <?xml version="1.0" encoding="utf-8"?>

Debug AnyCPU {183F8B86-9852-484B-80B3-B7B592DABC67} Library Properties Console.Data Console.Data v4.8 512 true SAK SAK SAK SAK true full false bin\Debug\ DEBUG;TRACE prompt 4 MinimumRecommendedRules.ruleset pdbonly true bin\Release\ TRACE prompt 4 bin\Production\ TRACE true pdbonly AnyCPU prompt MinimumRecommendedRules.ruleset bin\Test\ TRACE true pdbonly AnyCPU prompt MinimumRecommendedRules.ruleset bin\QA\ TRACE true pdbonly AnyCPU prompt MinimumRecommendedRules.ruleset true bin\Remote Debug\ DEBUG;TRACE full AnyCPU 7.3 prompt MinimumRecommendedRules.ruleset 201906221234392_AddTables.cs 201906221246469_EmptyMigration.cs 201906261505231_industry.cs 201906301246530_database-version.cs 201907021057293_performance-edit.cs 201907071342556_tenant-app-links.cs 201907080611146_contact-us.cs 201907090611215_tenant-theme.cs 201907101414540_currency-exchange.cs 201907110608014_FixContract.cs 201907141028181_store-type.cs 201907141040567_store-type-tenant-required.cs 201907150254464_EmptyMigration1.cs 201907161008552_FixThemes.cs 201907180550369_contract.cs 201907211303461_Build-queue.cs 201907231356141_tenant-is-show-public.cs 201907251116336_invocie-search-user.cs 201908042009588_contract-renew1.cs 201908042011511_contract-renew2.cs 201908042014459_contract-renew3.cs 201908251603248_invoice-edit.cs 201909120213174_RemoveStorTypFromTenantConsole.cs 201909270555030_RemoveEditUtc.cs 201909300108337_AddGoLiveScore.cs 201910070206430_AddRoundTextColor.cs 201910140447464_RemoveCans.cs 201911190559473_FixingArea.cs 201911260048386_RemoveEncodingLimit.cs 201912090550058_ImproveTrCOnsole.cs 201912300419003_createIndexOnCreateUtc.cs 202002020520288_AddNsProjects.cs 202002030516005_EmptyMig.cs 202002051125547_Fixes.cs 202002161055508_EmptyMig1.cs 202002172337326_AddImageRatio.cs 202002190036258_EmptyMig2.cs 202002240327522_FixCurncyNAme.cs 202002260045580_EmptyMig3.cs 202003040300039_AddExceptionVersion.cs 202003040318239_AddExceptionIP.cs 202003191149430_Fix.cs 202004030646020_loadthreshold.cs 202004160830120_addBuildNumber.cs 202004181346159_errorNameNotReq.cs 202004190259397_addTimeZoneToCountry.cs 202004190436092_ClearOldBuildQueue.cs 202004190441516_ConfigBuildQueue.cs 202004190502425_ConfigBuildQueue1.cs 202004190704321_ImproveExceptionVersion.cs 202004200033526_AddAPKAABTobuildQue.cs 202004221604471_FixBuildQueue.cs 202004231620105_FixTenantTr.cs 202004232343177_AddServerOs.cs 202004280155141_MakeSessionBrowserNameLonger.cs 202005021137442_AddStoreInfo.cs 202005021152077_AddStoreInfo1.cs 202005090322469_RemoveExceptionMaxLength.cs 202005280241065_AddServiceHistory.cs 202006070310452_EmptyMig4.cs 202006100223510_SeedNewAreas.cs 202006101357244_SeedNewLang.cs 202006110051587_AddFirebase.cs 202006111549408_EmptyMig5.cs 202006122258063_CityNotRequired.cs 202007030215415_RemoveCreateUtcComutedAttr.cs 202007230729227_makeNsTitleLongr.cs 202008030014145_TenantIsBuildable.cs 202008122319455_AddSystemConfiguration.cs 202008310114262_AddTenantStatuss.cs 202008310716285_AddVersions.cs 202009090050014_AddTenantToStoreType.cs 202009191136346_FixTenantStatus.cs 202010050326311_AddUserExceptionStory.cs App.config App.config App.config App.config App.config App.config {85c655ed-bdc3-4854-ad03-6e691d35653d} Console.Domain {23d4d11d-63b1-42ba-bb77-a9d5154ecdbe} Core {216E9825-BBEE-4A46-908B-7AA7B286DCBF} Data {56ebde0e-254a-4523-a9da-12c9df0a6a34} Domain 6.0.0 6.4.4 3.3.0 runtime; build; native; contentfiles; analyzers; buildtransitive all 3.6.0 4.3.0 1.0.8 4.3.4 4.3.1 201906221234392_AddTables.cs 201906221246469_EmptyMigration.cs 201906261505231_industry.cs 201906301246530_database-version.cs 201907021057293_performance-edit.cs 201907071342556_tenant-app-links.cs 201907080611146_contact-us.cs 201907090611215_tenant-theme.cs 201907101414540_currency-exchange.cs 201907110608014_FixContract.cs 201907141028181_store-type.cs 201907141040567_store-type-tenant-required.cs 201907150254464_EmptyMigration1.cs 201907161008552_FixThemes.cs 201907180550369_contract.cs 201907211303461_Build-queue.cs 201907231356141_tenant-is-show-public.cs 201907251116336_invocie-search-user.cs 201908042009588_contract-renew1.cs 201908042011511_contract-renew2.cs 201908042014459_contract-renew3.cs 201908251603248_invoice-edit.cs 201909120213174_RemoveStorTypFromTenantConsole.cs 201909270555030_RemoveEditUtc.cs 201909300108337_AddGoLiveScore.cs 201910070206430_AddRoundTextColor.cs 201910140447464_RemoveCans.cs 201911190559473_FixingArea.cs 201911260048386_RemoveEncodingLimit.cs 201912090550058_ImproveTrCOnsole.cs 201912300419003_createIndexOnCreateUtc.cs 202002020520288_AddNsProjects.cs 202002030516005_EmptyMig.cs 202002051125547_Fixes.cs 202002161055508_EmptyMig1.cs 202002172337326_AddImageRatio.cs 202002190036258_EmptyMig2.cs 202002240327522_FixCurncyNAme.cs 202002260045580_EmptyMig3.cs 202003040300039_AddExceptionVersion.cs 202003040318239_AddExceptionIP.cs 202003191149430_Fix.cs 202004030646020_loadthreshold.cs 202004160830120_addBuildNumber.cs 202004181346159_errorNameNotReq.cs 202004190259397_addTimeZoneToCountry.cs 202004190436092_ClearOldBuildQueue.cs 202004190441516_ConfigBuildQueue.cs 202004190502425_ConfigBuildQueue1.cs 202004190704321_ImproveExceptionVersion.cs 202004200033526_AddAPKAABTobuildQue.cs 202004221604471_FixBuildQueue.cs 202004231620105_FixTenantTr.cs 202004232343177_AddServerOs.cs 202004280155141_MakeSessionBrowserNameLonger.cs 202005021137442_AddStoreInfo.cs 202005021152077_AddStoreInfo1.cs 202005090322469_RemoveExceptionMaxLength.cs 202005280241065_AddServiceHistory.cs 202006070310452_EmptyMig4.cs 202006100223510_SeedNewAreas.cs 202006101357244_SeedNewLang.cs 202006110051587_AddFirebase.cs 202006111549408_EmptyMig5.cs 202006122258063_CityNotRequired.cs 202007030215415_RemoveCreateUtcComutedAttr.cs 202007230729227_makeNsTitleLongr.cs 202008030014145_TenantIsBuildable.cs 202008122319455_AddSystemConfiguration.cs 202008310114262_AddTenantStatuss.cs 202008310716285_AddVersions.cs 202009090050014_AddTenantToStoreType.cs 202009191136346_FixTenantStatus.cs 202010050326311_AddUserExceptionStory.cs $(TargetFileName).config $(_DeploymentApplicationDir)$(TargetName)$(TargetExt).config$(_DeploymentFileMappingExtension) `
ErikEJ commented 4 years ago

I need a full repro solution, as I cannot reproduce.

as206em commented 4 years ago

actually, I was deleting some projects from my solution to send it to you and I have tried once before sending and it works. I went back to my original solution and unload all unnecessary projects and I have made the views successfully. so I think in my case it's totally related to something in other projects.

ErikEJ commented 4 years ago

Closing this as no repro received, feel free to re-open if you can provide one.

ErikEJ commented 3 years ago

@reactor-gonguela Latest daily build includes much improved error logging for this issue.

domehead100 commented 3 years ago

I installed the latest daily build, and got the not very helpful output below "An error occurred while trying to generate views for CodingModel".

How does one debug the tool to discover where the error is occurring?

System.AggregateException: One or more errors occurred. ---> Microsoft.DbContextPackage.Extensions.EdmSchemaErrorException: An error occurred while trying to generate views for CodingModel.
   at Microsoft.DbContextPackage.Handlers.OptimizeContextHandler.<>c__DisplayClass6_0.<OptimizeContextEF6>b__0(String viewsPath)
   at Microsoft.DbContextPackage.Handlers.OptimizeContextHandler.<>c__DisplayClass4_1.<OptimizeContextCore>b__1()
   at System.Threading.Tasks.Task.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
   --- End of inner exception stack trace ---
---> (Inner Exception #0) Microsoft.DbContextPackage.Extensions.EdmSchemaErrorException: An error occurred while trying to generate views for CodingModel.
   at Microsoft.DbContextPackage.Handlers.OptimizeContextHandler.<>c__DisplayClass6_0.<OptimizeContextEF6>b__0(String viewsPath)
   at Microsoft.DbContextPackage.Handlers.OptimizeContextHandler.<>c__DisplayClass4_1.<OptimizeContextCore>b__1()
   at System.Threading.Tasks.Task.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()<---
ErikEJ commented 3 years ago

Are you able to provide a sample project and I will have a look - looks like there is room for even more improvement

domehead100 commented 3 years ago

Sorry, haven't been able to create a repro project and probably wouldn't be able to anyway. There is probably something wrong in our database project itself or with the edmx, probably due to a merge that someone did, though both projects build fine. We have another team that started "helping out" on our project and they don't exactly know what they're doing and things like bad merges of files that should not ever be merged in the first place are occurring (e.g., trying to actually merge an edmx file).

When this happened a week or two ago, I reverted the edmx and sqlproj back to a known good state, and then generating views worked fine, so I then applied all of the schema changes manually and then everything worked.

I wonder if there is some kind of caching going on in Visual Studio or something where things get in a bad state; I've also had some issues due to these bad merges (I think) wherein my app will apaprently go into an infinite recursion and will blow out the stack and exit hard when attempting to use the dbcontext for certain model objects only, so probably that's where the actual problem lies. (Again, everything builds fine).

So now some more checkins have occurred from this other team, and now I'm back to the same place and basically the same error "an error occurred".

I was serious about asking how one might debug this, as in run the generate views manually as a separate executable and debug it, or if there are any suggestions you have that would be great.

ErikEJ commented 3 years ago

@domehead100 Clone this repo, set a breakpoint in the OptimizeContextHandler, and press F5.