ErikEJ / EFCorePowerTools

Entity Framework Core Power Tools - reverse engineering, migrations and model visualization in Visual Studio & CLI
MIT License
2.18k stars 298 forks source link

rev-eng with EDMX shows NULLReferenceExeption in output [Firebird] #904

Closed MagicAndre1981 closed 3 years ago

MagicAndre1981 commented 3 years ago

When I use EDMX with firebird which works with EF6 and selecting the EDMX in Rev-Eng. UI the VS shows a NULLReferenceExeption in output:

System.Exception: Table list error: 
System.NullReferenceException: Object reference not set to an instance of an object.
   at XTypedElement Xml.Schema.Linq.XTypedServices.GetAnnotation(Type t, XElement xe)
   at XTypedElement Xml.Schema.Linq.XTypedServices.ToXTypedElement(XElement xe, ILinqToXsdTypeManager typeManager, Type rootType, Type contentType)
   at W Xml.Schema.Linq.XTypedServices.ToXTypedElement<W, T>(XElement xe, ILinqToXsdTypeManager typeManager)
   at StorageSchema LinqToEdmx.Model.StorageV3.StorageSchema.op_Explicit(XElement xe)
   at StorageSchema LinqToEdmx.DesignerV3.StorageModels.get_StorageSchema()
   at DatabaseModel ErikEJ.EntityFrameworkCore.SqlServer.Edmx.Scaffolding.SqlServerEdmxDatabaseModelFactory.Create(string edmxPath, DatabaseModelFactoryOptions options) in C:/Code/EFCorePowerTools/src/GUI/ErikEJ.EntityFrameworkCore.SqlServer.Edmx/Scaffolding/SqlServerEdmxDatabaseModelFactory.cs:line 93
   at List<DatabaseTable> RevEng.Core.TableListBuilder.GetTableDefinitions() in C:/Code/EFCorePowerTools/src/GUI/RevEng.Core/TableListBuilder.cs:line 66
   at List<TableModel> RevEng.Core.TableListBuilder.GetTableModels() in C:/Code/EFCorePowerTools/src/GUI/RevEng.Core/TableListBuilder.cs:line 40
   at int efreveng.Program.Main(string[] args) in C:/Code/EFCorePowerTools/src/GUI/efreveng/Program.cs:line 30

Originally posted by @MagicAndre1981 in https://github.com/ErikEJ/EFCorePowerTools/issues/812#issuecomment-812995878

omatrot commented 3 years ago

Could you share your edmx file ? If not, It would be great for me to have instructions on how to generate one from VS 2019. Thanks in advance.

EDIT: I mean how to have a DDEX provider installed.

MagicAndre1981 commented 3 years ago

EDIT: I mean how to have a DDEX provider installed.

firebird misses DDEX in VSIX format, so after auch extension update you have to do this again:

https://www.tabsoverspaces.com/233604-installing-ddex-provider-for-firebird-into-visual-studio-2017

omatrot commented 3 years ago

I'm surprised you hit this error because: 1) You're supposed to be stopped earlier with a NotSupportedException => "Only SQL Server EDMX files are currently supported"

System.Exception: Table list error: 
System.NotSupportedException: Only SQL Server EDMX files are currently supported
   at DatabaseModel ErikEJ.EntityFrameworkCore.SqlServer.Edmx.Scaffolding.SqlServerEdmxDatabaseModelFactory.Create(string edmxPath, DatabaseModelFactoryOptions options) in C:/Code/EFCorePowerTools/src/GUI/ErikEJ.EntityFrameworkCore.SqlServer.Edmx/Scaffolding/SqlServerEdmxDatabaseModelFactory.cs:line 121
   at List<DatabaseTable> RevEng.Core.TableListBuilder.GetTableDefinitions() in C:/Code/EFCorePowerTools/src/GUI/RevEng.Core/TableListBuilder.cs:line 66
   at List<TableModel> RevEng.Core.TableListBuilder.GetTableModels() in C:/Code/EFCorePowerTools/src/GUI/RevEng.Core/TableListBuilder.cs:line 40
   at int efreveng.Program.Main(string[] args) in C:/Code/EFCorePowerTools/src/GUI/efreveng/Program.cs:line 30

   at EFCorePowerTools.Handlers.ReverseEngineer.ResultDeserializer.BuildTableResult(String output) in C:\projects\efcorepowertools\src\GUI\EFCorePowerTools\Handlers\ReverseEngineer\ResultDeserializer.cs:line 46
   at EFCorePowerTools.Handlers.ReverseEngineer.EfRevEngLauncher.GetTablesInternal(String arguments) in C:\projects\efcorepowertools\src\GUI\EFCorePowerTools\Handlers\ReverseEngineer\EfRevEngLauncher.cs:line 105
   at EFCorePowerTools.Handlers.ReverseEngineer.EfRevEngLauncher.GetTables(String connectionString, DatabaseType databaseType, SchemaInfo[] schemas) in C:\projects\efcorepowertools\src\GUI\EFCorePowerTools\Handlers\ReverseEngineer\EfRevEngLauncher.cs:line 82
   at EFCorePowerTools.Handlers.ReverseEngineer.ReverseEngineerHandler.<>c__DisplayClass16_0.<GetDacpacTablesAsync>b__0() in C:\projects\efcorepowertools\src\GUI\EFCorePowerTools\Handlers\ReverseEngineer\ReverseEngineerHandler.cs:line 595
   at System.Threading.Tasks.Task`1.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at EFCorePowerTools.Handlers.ReverseEngineer.ReverseEngineerHandler.<GetDacpacTablesAsync>d__16.MoveNext() in C:\projects\efcorepowertools\src\GUI\EFCorePowerTools\Handlers\ReverseEngineer\ReverseEngineerHandler.cs:line 595
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at EFCorePowerTools.Handlers.ReverseEngineer.ReverseEngineerHandler.<LoadDataBaseObjectsAsync>d__10.MoveNext() in C:\projects\efcorepowertools\src\GUI\EFCorePowerTools\Handlers\ReverseEngineer\ReverseEngineerHandler.cs:line 329
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at EFCorePowerTools.Handlers.ReverseEngineer.ReverseEngineerHandler.<ReverseEngineerCodeFirstAsync>d__6.MoveNext() in C:\projects\efcorepowertools\src\GUI\EFCorePowerTools\Handlers\ReverseEngineer\ReverseEngineerHandler.cs:line 146

2) Despite the fact that there is no notion of schema in a Firebird database, a default one Firebird is to be found in the EDMX I generated:

I started from here, the v3 examples.fdb database.

<EntitySet Name="CUSTOMER" EntityType="Self.CUSTOMER" Schema="Firebird" store:Type="Tables" />
<EntitySet Name="INVOICE" EntityType="Self.INVOICE" Schema="Firebird" store:Type="Tables" />
<EntitySet Name="INVOICE_LINE" EntityType="Self.INVOICE_LINE" Schema="Firebird" store:Type="Tables" />
<EntitySet Name="PRODUCT" EntityType="Self.PRODUCT" Schema="Firebird" store:Type="Tables" />
<EntitySet Name="users" EntityType="Self.users" Schema="Firebird" store:Type="Tables" />
<EntitySet Name="WEBROLE" EntityType="Self.WEBROLE" Schema="Firebird" store:Type="Tables" />
<EntitySet Name="WEBUSER" EntityType="Self.WEBUSER" Schema="Firebird" store:Type="Tables" />
<EntitySet Name="WEBUSERINROLE" EntityType="Self.WEBUSERINROLE" Schema="Firebird" store:Type="Tables" />

If I go beyond the NotSupportedException, I'm not hitting the exception you show above.

I'm not sure what you did exactly, but I'd like to know. Please either provide your EDMX file or describe your Firebird setup.

MagicAndre1981 commented 3 years ago

I open the Rev-Eng UI and select the EDMX, next I see this exception in output. I use FB 3.0.7, so nothing special. I'll try other EDMXs next week

ErikEJ commented 3 years ago

Just share the .EDMX file with us, please!

omatrot commented 3 years ago

Besides the EDMX, what version of the ADO.NET / DDEX provider are you using ?

Mine are:

MagicAndre1981 commented 3 years ago

I use latest FirebirdSql.Data.FirebirdClient.dll 8.0.0 and the same DDEX version and I'm not allowed to share the EDMX.

MagicAndre1981 commented 3 years ago

I'm surprised you hit this error because:

  1. You're supposed to be stopped earlier with a NotSupportedException => "Only SQL Server EDMX files are currently supported"

this should be also shown via message box as clear error message and not in output as exception. Maybe this can be improved.

ErikEJ commented 3 years ago

If you are not able to provide a repro .EDMX file we cannot assist, sorry.

MagicAndre1981 commented 3 years ago

If you are not able to provide a repro .EDMX file we cannot assist, sorry.

my VS2019 was broken, I had also errors in other areas. So I did a repair install and now I also get the NotSupportedException => "Only SQL Server EDMX files are currently supported" output.

erikej_EFcore_pt_EDMX

ErikEJ commented 3 years ago

Perfect, thanks for the update