Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to use with a project that targets x64 #55

Closed
jmoleary opened this issue Jun 19, 2018 · 6 comments
Closed

Unable to use with a project that targets x64 #55

jmoleary opened this issue Jun 19, 2018 · 6 comments

Comments

@jmoleary
Copy link

I'm not sure if this is a bug or intentional design but if it is the latter I'm hoping for a workaround if you know of one.

I have a .NET class library that targets x64 as its build target. Whenever I try to do "View DbContext Model DDL SQL" from the EFCore Power Tools (EFCPT) menu the build fails with the error that it cannot load my file or assembly because it was "compiled for a different processor"

If I change the build target to "Any CPU", then EFCPT works fine. Unfortunately I cannot change the target of my project for other reasons.

Steps to reproduce

  1. Take that sample project I gave you in Issue Error about dependency on System.ValueTuple 4.0.2.0 #52 (which you just fixed, thank you).
  2. In Project Properties >> Build Change the "Platform Target" to "x64".
  3. Build the project - it builds
  4. From the EFCore Power Tools context menu, choose "View DbContext Model DDL SQL". You will get the following output:

System.ArgumentException: Error:
System.BadImageFormatException: Could not load file or assembly 'TestEFPowerTools, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. This assembly was compiled for a different processor.
at System.Reflection.RuntimeAssembly.nLoadFile(String path, Evidence evidence)
at System.Reflection.Assembly.LoadFile(String path)
at ReverseEngineer20.EfCoreModelBuilder.Load(String assemblyPath)
at ReverseEngineer20.EfCoreModelBuilder.GetOperations(String outputPath)
at ReverseEngineer20.EfCoreModelBuilder.BuildResult(String outputPath, Boolean generateDdl)
at ReverseEngineer20.EfCoreModelBuilder.GenerateDatabaseCreateScript(String outputPath)
at ReverseEngineer20.Program.Main(String[] args)

Parameter name: processResult
at EFCorePowerTools.Handlers.ModelAnalyzerHandler.Generate(String outputPath, Project project, GenerationType generationType) in C:\projects\efcorepowertools\src\GUI\EFCorePowerTools\Handlers\ModelAnalyzerHandler.cs:line 49

Further technical details

EF Core Power Tools version: Version 1.0.618.0
SQL Server Compact 4.0 in GAC - Yes - 4.0.8876.1
SQL Server Compact 4.0 DbProvider - Yes
SQL Server Compact 4.0 DDEX provider - No
SQL Server Compact 4.0 Simple DDEX provider - Yes
SQLite ADO.NET Provider included: 1.0.107.0
SQLite EF6 DbProvider in GAC - No
System.Data.SQLite DDEX provider - No
SQLite Simple DDEX provider - Yes
Database engine: (SQlite, SQL Compact, SQL Server, Postgres)
Visual Studio version: 15.7.3

@ErikEJ
Copy link
Owner

ErikEJ commented Jun 19, 2018

Please explain why you cannot target AnyCPU?
Can you move your x64 dependencies to another project?

@jmoleary
Copy link
Author

Engineering resources. We make (and my .NET code uses) a 64-bit only C++ SDK that we access through C++/CLI. We cannot isolate it.

@jmoleary
Copy link
Author

If this (Any CPU or bust) is just the way it is, I understand and still appreciate your effort. I just wanted to check

@ErikEJ
Copy link
Owner

ErikEJ commented Jun 19, 2018

You are unable to isolate your DbContext in a separate project??

Never give up, I will add the feature to generate SQL scripts to my dgml Nuget library!

@jmoleary
Copy link
Author

jmoleary commented Jun 19, 2018 via email

@ErikEJ
Copy link
Owner

ErikEJ commented Jun 20, 2018

I have added a AsSqlScript extension method to my NuGet package here: https://www.nuget.org/packages/ErikEJ.EntityFrameworkCore.DgmlBuilder/2.1.1

@ErikEJ ErikEJ closed this as completed Jun 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants