Error "Table Definition for <entity> has not been inferred."
See original GitHub issueWhen 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:
- Created a year ago
- Comments:10 (10 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Let’s generate the entity name using the same casing used in the configuration file
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.