When using the default security option the tables are created under dbo in the ssms database. Is there a way to change what schema it goes under?
Hi @ms5770,
You can try the following:
- Create a new partial class for the ApplicationIdentityDbContext
- Specify its OnModelBuilding partial method:
public partial class ApplicationIdentityDbContext
{
partial void OnModelBuilding(DbModelBuilder modelBuilder)
{
// You can globally assign schema here
modelBuilder.HasDefaultSchema("schemaName");
}
}
There is a chance this could fail because the tables already exist in your dbo schema. In such case you will need to drop all ASP.NET Identity tables as well as the Eentity Framework Core migration table.
After adding that line of code, do I just need to build the app again? If not, what steps do I need to take?
You will have to delete all tables created in the dbo schema. Also the entity framework migration table.
I've added a new file named ApplicationIdentityDbContext.Custom.cs, deleted all the tables in the DB, and hit run on Radzen, but the tables are still being added to the dbo schema.
Is this how I should be implementing the code?
This looks correct and I hoped it would work according to the Entity Framework Core documentation. Does this schema exist?
Yes the schema does exist.
Do you think changing the schema manually through ssms would work?
You can try but there is a chance the entity framework queries will not work afterwards.
I used 2 different users and data sources.
The sa login which uses the dbo schema and a user called radzen which used a new schema called Security
I then used the sa login to attach the tables and then created a 2nd datasource called NewSchema
This datasource I didnt attach any tables to it
I then went to the security tab and select NewSchema as my datasource
Running the application I got the security schema created for the applications security tables