3

I'm starting to develop an MVC application that will use the ASP.NET authentication tables (aspnet_Users, aspnet_Roles, etc...). I'm going to install them on the same database as the rest of my application, to allow the use of foreign keys.

I would like, however, for better separation, to install them on a different schema, and not the default. Is that possible?

0

1 Answer 1

2

I think this should be possible because db schema is linked to sql user and you can define the user that will connect to database while aspnet_regsql generates tables and stored procedures.

Take a look at this command: aspnet_regsql -S myMachine -U "MySqlUser" -P "mypassword" -d mydatabase -A all

Just change "MySqlUser" schema inside SQL Server and start aspnet_regsql.

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

5 Comments

I must say I did not try this. However if MS has hardcoded dbo schema inside script you can still use Sql Managment Studio to get creation scripts for all objects inside db. Then just use notepad and replace old schema with new and run this script. This should work for sure.
I doubt changing schema names by hand will work, because I'll need to change all the code that accesses the tables as well. I don't want to do that. I'll tell you how it goes in a few minutes.
No, this didn't work. The tables were all created under the dbo schema.
I renamed the schema as you suggested in your comments, now I'll check if the ASP.NET code keeps working here...
Oooh, the ASP.NET code also creates multiple schemas of its own. I don't want to mess with renaming tables, I'll just get used to those tables in my database and that's it. Thanks anyway.

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.