创建ASP。NET用户和角色表位于不同的数据库模式上

时间:2021-09-28 12:46:59

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.

我开始开发一个使用ASP的MVC应用程序。NET认证表(aspnet_Users, aspnet_Roles,等等…)。我将把它们安装到与应用程序其他部分相同的数据库中,以允许使用外键。

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

但是,为了更好地分离,我希望将它们安装在不同的模式上,而不是默认模式。这有可能吗?

1 个解决方案

#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.

我认为这应该是可能的,因为db模式链接到sql用户,您可以定义将连接到数据库的用户,同时aspnet_regsql生成表和存储过程。

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

请看这个命令:aspnet_regsql -S myMachine -U“MySqlUser”-P“mypassword”-d mydatabase -A all

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

只需在SQL Server中更改“MySqlUser”模式并启动aspnet_regsql。

#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.

我认为这应该是可能的,因为db模式链接到sql用户,您可以定义将连接到数据库的用户,同时aspnet_regsql生成表和存储过程。

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

请看这个命令:aspnet_regsql -S myMachine -U“MySqlUser”-P“mypassword”-d mydatabase -A all

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

只需在SQL Server中更改“MySqlUser”模式并启动aspnet_regsql。