October 18, 2022 by Anuraj Estimated read time : 2 mins
This post is about how to change schema name in EF Core. By default when we are running EF Core migrations, EF Core will create tables in the default dbo schema. We can change it with fluent API and using attributes.
In the fluent API, we can configure the schema with HasDefaultSchema method, which will apply the schema for all the tables. And if you want only for specific tables, we can use the ToTable method overload. Here is pseudo code.
And here is the implementation using the ToTable data annotations attributes.
Using these two ways we will be able to customize the EF Core database schema.