Skip to content
New issue

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

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

Already on GitHub? # to your account

EntityFramework SqlServer WebhookDbContext schema issue #64

Closed
qsngoon opened this issue Apr 14, 2024 · 1 comment · Fixed by #65
Closed

EntityFramework SqlServer WebhookDbContext schema issue #64

qsngoon opened this issue Apr 14, 2024 · 1 comment · Fixed by #65
Assignees
Labels
bug Something isn't working

Comments

@qsngoon
Copy link

qsngoon commented Apr 14, 2024

SQL Server database table creation issue for the following foreign keys :-

Table - [webhook_delivery_results]

Cannot create the foreign key "FK_webhook_delivery_results_event_info_event_id" with the SET NULL referential action, because one or more referencing columns are not nullable.

Cannot create the foreign key "FK_webhook_delivery_results_webhook_receivers_receiver_id" with the SET NULL referential action, because one or more referencing columns are not nullable.

Cannot create the foreign key "FK_webhook_delivery_results_webhooks_WebhookId" with the SET NULL referential action, because one or more referencing columns are not nullable.

Code example:

builder.Services.AddWebhookSubscriptions<DbWebhookSubscription>()
    .UseEntityFramework(ef => 
        ef.UseContext(options => 
            options.UseSqlServer(builder.Configuration.GetConnectionString(nameof(WebhookDbContext)))));

using (var scope = app.Services.CreateScope())
{
    var dataContext = scope.ServiceProvider.GetRequiredService<WebhookDbContext>();
    dataContext.Database.EnsureCreated();   
}

The foreign key constraints possible requires to be delete on cascade?

@qsngoon qsngoon added the bug Something isn't working label Apr 14, 2024
@tsutomi tsutomi self-assigned this Aug 31, 2024
@tsutomi
Copy link
Member

tsutomi commented Aug 31, 2024

Thank you @qsngoon for the notification of this bug. In fact, as you can see from the code, I have used only SQLite to test the Entity Framework data layer, and this aspect didn't emerge before.

I have created a test suite to use MS SQL Server as one of the reference databases for the Entity Framework data layer, and I was able to reproduce the issue, quickly fixing it.

Soon I will push the fix.

@tsutomi tsutomi linked a pull request Sep 1, 2024 that will close this issue
tsutomi added a commit that referenced this issue Sep 2, 2024
…okdbcontext-schema-issue

Fixes to Entity Framework Configuration Bug #64
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants