Azure / Azure/data-api-builder

[Bug]: MSSQL - Cannot obtain Schema for entity - Geography data type

Offen
#1,397 5 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
bug cri
Vorherrschende Sprache
C#
Sterne
1.5k
Forks
370
Ø Merge
3 T. 22 Std.
Gemergte PRs (30 T.)
9

Beschreibung

### What happened?

I have tried to use DAB to expose Sales.Customer table from World Wide Importers database. DAB fails to start with the exception reported below. If I try to publish a non SystemVersioned Table (Sales.Orders, Sales.Invoices, etc) it works perfectly so I think this is due to the fact that Sales.Customers is a System-Versioned table in SQL.

I was able to repro the error in Visual Studio and it seems that exception is raised from the FillSchema method of the DbDataAdapter in the System.Data.Common but not sure about the reason.

Thanks

### Version

0.5.34

### What database are you using?

Azure SQL

### What hosting model are you using?

Local (including CLI)

### Which API approach are you accessing DAB through?

REST, GraphQL

### Relevant log output

```Text
Information: Microsoft.DataApiBuilder 0.5.34
Information: Config not provided. Trying to get default config based on DAB_ENVIRONMENT...
Found config file: dab-config.json.
Information: Setting default minimum LogLevel: Debug for Development mode.
Starting the runtime engine...
info: Azure.DataApiBuilder.Service.Configurations.RuntimeConfigProvider[0]
Using file dab-config.json to configure the runtime.
info: Azure.DataApiBuilder.Service.Configurations.RuntimeConfigProvider[0]
GraphQL type for Invoice is Invoice
info: Azure.DataApiBuilder.Service.Configurations.RuntimeConfigProvider[0]
GraphQL type for InvoiceLine is InvoiceLine
info: Azure.DataApiBuilder.Service.Configurations.RuntimeConfigProvider[0]
GraphQL type for Order is Order
info: Azure.DataApiBuilder.Service.Configurations.RuntimeConfigProvider[0]
GraphQL type for OrderLine is OrderLine
info: Azure.DataApiBuilder.Service.Configurations.RuntimeConfigProvider[0]
GraphQL type for Customer is Customer
info: Azure.DataApiBuilder.Service.Configurations.RuntimeConfigProvider[0]
Runtime configuration has been successfully loaded.
info: Azure.DataApiBuilder.Service.Configurations.RuntimeConfigProvider[0]
GraphQL path: /graphql
info: Azure.DataApiBuilder.Service.Configurations.RuntimeConfigProvider[0]
StaticWebApps
info: Azure.DataApiBuilder.Service.Configurations.RuntimeConfigProvider[0]
Runtime config loaded from file.
info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[63]
User profile is available. Using 'C:\Users\sbanchie\AppData\Local\ASP.NET\DataProtection-Keys' as key repository and Windows DPAPI to encrypt keys at rest.
info: Azure.DataApiBuilder.Service.Services.ISqlMetadataProvider[0]
Invoice path: /api/Invoice
info: Azure.DataApiBuilder.Service.Services.ISqlMetadataProvider[0]
InvoiceLine path: /api/InvoiceLine
info: Azure.DataApiBuilder.Service.Services.ISqlMetadataProvider[0]
Order path: /api/Order
info: Azure.DataApiBuilder.Service.Services.ISqlMetadataProvider[0]
OrderLine path: /api/OrderLine
info: Azure.DataApiBuilder.Service.Services.ISqlMetadataProvider[0]
Customer path: /api/Customer
fail: Azure.DataApiBuilder.Service.Startup[0]
Unable to complete runtime initialization operations due to:
Azure.DataApiBuilder.Service.Exceptions.DataApiBuilderException: Cannot obtain Schema for entity Customer with underlying database object source: Sales.Customers due to: DataReader.GetFieldType(24) returned null.
at Azure.DataApiBuilder.Service.Services.SqlMetadataProvider`3.GetTableWithSchemaFromDataSetAsync(String entityName, String schemaName, String tableName)
at Azure.DataApiBuilder.Service.Services.SqlMetadataProvider`3.PopulateSourceDefinitionAsync(String entityName, String schemaName, String tableName, SourceDefinition sourceDefinition, String[] runtimeConfigKeyFields)
at Azure.DataApiBuilder.Service.Services.SqlMetadataProvider`3.PopulateObjectDefinitionForEntities()
at Azure.DataApiBuilder.Service.Services.SqlMetadataProvider`3.InitializeAsync()
at Azure.DataApiBuilder.Service.Startup.PerformOnConfigChangeAsync(IApplicationBuilder app)
info: Azure.DataApiBuilder.Service.Startup[0]
Loading config file: dab-config.json
fail: Azure.DataApiBuilder.Service.Startup[0]
Exiting the runtime engine...
crit: Microsoft.AspNetCore.Hosting.Diagnostics[6]
Application startup exception
System.ApplicationException: Could not initialize the engine with the runtime config file: dab-config.json
at Azure.DataApiBuilder.Service.Startup.Configure(IApplicationBuilder app, IWebHostEnvironment env, RuntimeConfigProvider runtimeConfigProvider)
at System.RuntimeMethodHandle.InvokeMethod(Object target, Span`1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Microsoft.AspNetCore.Hosting.ConfigureBuilder.Invoke(Object instance, IApplicationBuilder builder)
at Microsoft.AspNetCore.Hosting.ConfigureBuilder.<>c__DisplayClass4_0.b__0(IApplicationBuilder builder)
at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.<>c__DisplayClass15_0.b__1(IApplicationBuilder app)
at Microsoft.AspNetCore.Mvc.Filters.MiddlewareFilterBuilderStartupFilter.<>c__DisplayClass0_0.g__MiddlewareFilterBuilder|0(IApplicationBuilder builder)
at Microsoft.AspNetCore.HostFilteringStartupFilter.<>c__DisplayClass0_0.b__0(IApplicationBuilder app)
at Microsoft.AspNetCore.Hosting.GenericWebHostService.StartAsync(CancellationToken cancellationToken)
Unable to launch the runtime due to: System.ApplicationException: Could not initialize the engine with the runtime config file: dab-config.json
at Azure.DataApiBuilder.Service.Startup.Configure(IApplicationBuilder app, IWebHostEnvironment env, RuntimeConfigProvider runtimeConfigProvider)
at System.RuntimeMethodHandle.InvokeMethod(Object target, Span`1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Microsoft.AspNetCore.Hosting.ConfigureBuilder.Invoke(Object instance, IApplicationBuilder builder)
at Microsoft.AspNetCore.Hosting.ConfigureBuilder.<>c__DisplayClass4_0.b__0(IApplicationBuilder builder)
at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.<>c__DisplayClass15_0.b__1(IApplicationBuilder app) at Microsoft.AspNetCore.Mvc.Filters.MiddlewareFilterBuilderStartupFilter.<>c__DisplayClass0_0.g__MiddlewareFilterBuilder|0(IApplicationBuilder builder)
at Microsoft.AspNetCore.HostFilteringStartupFilter.<>c__DisplayClass0_0.b__0(IApplicationBuilder app)
at Microsoft.AspNetCore.Hosting.GenericWebHostService.StartAsync(CancellationToken cancellationToken)
at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost host)
at Azure.DataApiBuilder.Service.Program.StartEngine(String[] args)
Error: Failed to start the engine.
```

### Code of Conduct

- [X] I agree to follow this project's Code of Conduct

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Reproduziere den Fehler mit der Tabelle World Wide Importers Sales.Customers auf Azure SQL und untersuche anschließend SqlMetadataProvider.GetTableWithSchemaFromDataSetAsync sowie den im Bericht erwähnten DbDataAdapter FillSchema-Pfad. Verfolge, warum DataReader.GetFieldType(24) für die Geography-Spalte null zurückgibt; abgeschlossen ist die Aufgabe, wenn die Laufzeit erfolgreich initialisiert wird und die Entität verfügbar machen kann.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
azure, csharp, sql
Bereich
api, databases
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
30/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.