EF Core 6 Adding a table manually?

Cenk 956 Reputation points

Hello friends,

I am working on a web API project that I implemented with the code-first approach. I wonder if there is a problem creating tables manually without using migrations. Does it cause any problems?

Thank you.

Entity Framework Core
Entity Framework Core
A lightweight, extensible, open-source, and cross-platform version of the Entity Framework data access technology.
697 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Nieze Ben Mansour 0 Reputation points

    Hi Cenk, To create a table manually, you can create the table with SSMS (for example) after that, you scaffold the database to generate the entities.

    This a link for how to use Reverse Enginner: https://learn.microsoft.com/en-us/ef/core/managing-schemas/scaffolding/?tabs=dotnet-core-cli

  2. Jack J Jun 24,286 Reputation points Microsoft Vendor

    @Cenk T ,Welcome to Microsoft Q&A, we also could use ExecuteSqlRaw method to create the table.

    Here is a code example you could refer to.

    TeacherContext context=new TeacherContext();
    string sqltext = "create table Employee (empno int,empname varchar(50),salary money);";


    User's image

    Best Regards,


    If the answer is the right solution, please click "Accept Answer" and upvote it.If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.