question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error "Table Definition for <entity> has not been inferred."

See original GitHub issue

When trying to execute a query via GraphQL I get the following error:

{
  "errors": [
    {
      "message": "Table Definition for Todo has not been inferred.",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "todos"
      ]
    }
  ]
}

the stack dump is:

Table Definition for Todo has not been inferred.
   at Azure.DataGateway.Service.Services.SqlMetadataProvider`3.GetSchemaName(String entityName) in w:\_git\_hawaii\hawaii-engine\DataGateway.Service\Services\MetadataProviders\SqlMetadataProvider.cs:line 101
   at Azure.DataGateway.Service.Resolvers.SqlQueryStructure..ctor(IResolverContext ctx, IDictionary`2 queryParams, ISqlMetadataProvider sqlMetadataProvider, IObjectField schemaField, FieldNode queryField, IncrementingInteger counter, String entityName) in w:\_git\_hawaii\hawaii-engine\DataGateway.Service\Resolvers\Sql Query Structures\SqlQueryStructure.cs:line 297
   at Azure.DataGateway.Service.Resolvers.SqlQueryStructure..ctor(IResolverContext ctx, IDictionary`2 queryParams, ISqlMetadataProvider sqlMetadataProvider) in w:\_git\_hawaii\hawaii-engine\DataGateway.Service\Resolvers\Sql Query Structures\SqlQueryStructure.cs:line 103
   at Azure.DataGateway.Service.Resolvers.SqlQueryEngine.ExecuteAsync(IMiddlewareContext context, IDictionary`2 parameters) in w:\_git\_hawaii\hawaii-engine\DataGateway.Service\Resolvers\SqlQueryEngine.cs:line 68
   at Azure.DataGateway.Service.Services.ResolverMiddleware.InvokeAsync(IMiddlewareContext context) in w:\_git\_hawaii\hawaii-engine\DataGateway.Service\Services\ResolverMiddleware.cs:line 71
   at HotChocolate.Utilities.MiddlewareCompiler`1.ExpressionHelper.AwaitTaskHelper(Task task)
   at HotChocolate.Execution.Processing.Tasks.ResolverTask.ExecuteResolverPipelineAsync(CancellationToken cancellationToken)
   at HotChocolate.Execution.Processing.Tasks.ResolverTask.TryExecuteAsync(CancellationToken cancellationToken)

everything works fine if I execute a REST request.

The configuration schema is

{
    "$schema": "hawaii.draft-01.schema.json",
    "data-source": {
        "database-type": "mssql",
        "connection-string": "Server=localhost;Database=HawaiiTest;User ID=sa;Password=Passw0rd!;TrustServerCertificate=true"
    },
    "runtime": {
        "host": {
            "mode": "development",
            "authentication": {
                "provider": "AzureAD",
                "jwt": {
                  "audience": "e98794ab-cdaa-4ed3-ad08-0552c47254e2",
                  "issuer": "https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/v2.0"
                }
            }
        },
        "rest": {
            "enabled": true
        },
        "graphql": {
            "enabled": true
        }
    },
    "entities": {
        "todo": {
            "source": "s002.todos",
            "relationships": {
                "category": {
                    "cardinality": "one",                    
                    "target.entity": "category"                    
                }
            },
            "permissions": [
                {
                    "role": "anonymous",
                    "actions": [
                        "*"
                    ]
                }
            ]
        },
        "category": {
            "source": "s002.categories",
            "relationships": {
                "todos": {
                    "cardinality": "many",                    
                    "target.entity": "todo"
                }
            },
            "permissions": [
                {
                    "role": "anonymous",
                    "actions": [
                        "*"
                    ]
                }
            ]
        }
    }
}

and the database

drop table if exists s002.todos
drop table if exists s002.categories
drop sequence if exists s002.globalId
go

create sequence s002.globalId
as int start with 10000
go

create table s002.categories
(
	id int not null primary key default (next value for s002.globalId),
	category nvarchar(100) not null unique
)
go

create table s002.todos
(
	id int not null 
		default (next value for s002.globalId)
		constraint pk__s002_todos primary key,
	category_id int not null 
		constraint fk__s002_todos2__s002_categories references s002.categories(id),
	title nvarchar(100) not null,
	[description] nvarchar(1000) null,
	completed bit not null default(0)
)
go

insert into s002.categories
	(id, category)
values
	(1, 'Family'),
	(2, 'Work'),
	(3, 'Hobby'),
	(4, 'Car'),
	(5, 'Bike')
go

insert into s002.todos
	(title, completed, category_id)
values
	('item-001', 0, 1),
	('item-002', 1, 1),
	('item-003', 1, 2),
	('item-004', 0, 3),
	('item-005', 1, 4),
	('item-006', 0, 3),
	('item-007', 0, 4),
	('item-008', 1, 4),
	('item-009', 1, 1),
	('item-010', 0, 2),
	('item-011', 1, 3),
	('item-012', 0, 4),
	('item-013', 1, 5),
	('item-015', 1, 1),
	('item-016', 0, 2),
	('item-017', 0, 4),
	('item-018', 1, 5),
	('item-019', 1, 3),
	('item-019', 1, 1),
	('item-020', 0, 2)

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
yorekcommented, Jul 27, 2022

Let’s generate the entity name using the same casing used in the configuration file

0reactions
seantleonardcommented, Jul 27, 2022

One thing to keep in mind when handling entities and fields for GraphQL is the GraphQL Specification requirements for names: http://spec.graphql.org/draft/#sec-Names

This means that we will need make sure to enforce those constraints in our config when naming entities and fields.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error 6002: The table/view does not have a primary key ...
This doesn't work. I have a manually defined primary key on my view entity, on a unique column (which happens to be a...
Read more >
Views and Incorrect Data in Entity Framework - Dustin Horne
The issue is that Views are not going to have a primary key defined as tables do. Entity Framework will warn you that...
Read more >
Fixing issue of not being able to add view to Database First ...
Solution: Your view must have a column that it can infer as a Key. Not necessarily a primary Key but any key. Entity...
Read more >
Entity Framework ADO.net Entity Data Model not working
Hello , I observed that when I wand to add a new Model created from database is not working. Can you see in...
Read more >
Visual Studio error 6002 warning when add in entity ...
So I got the Entity framework to work with this oracle database that I am working on. However, when I created the emdx...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found