2

So I'm having trouble determining how to add tables dynamically in a .NET Core web application. From my research it doesn't appear entity framework supports this feature. It's my understanding that EF is static, so all new tables would need to be created through migrations.

So I have 2 questions:

  1. Am I missing a way to add a table (say on a button click) using EF in spite of its static nature?
  2. If #1 is not possible, is there any other way to dynamically add a table other than use sql commands like CREATE TABLE..., like using Linq?

1 Answer 1

1

There's no way you can perform DDL tasks with EF.

You can however abuse the EntityFrameworkCore.Migrations API if you want to. The docs are here: https://learn.microsoft.com/en-us/ef/core/api/microsoft.entityframeworkcore.migrations

If you intend to do so, be warned that the migrations API is not meant to be used this way. So things like SQL injection, etc. will have to be handled manually as far as I know (unless things changed in the recent past).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.