WebSecurity.InitializeDatabaseConnection - How specify a db schema?

后端 未结 4 1885
日久生厌
日久生厌 2021-01-05 23:16

I am using SimpleMembership (http://blog.osbornm.com/archive/2010/07/21/using-simplemembership-with-asp.net-webpages.aspx) but I am unable to have place my custom user table

4条回答
  •  天命终不由人
    2021-01-05 23:57

    Version 2.0.0.0 of the WebMatrix.WebData assembly generates its create table statement as follows.

    "CREATE TABLE " + this.SafeUserTableName + "(" + this.SafeUserIdColumn + " int NOT NULL PRIMARY KEY IDENTITY, " + this.SafeUserNameColumn + " nvarchar(56) NOT NULL UNIQUE)"
    

    SafeUserTableName has the following implementation.

    return "[" + this.UserTableName + "]";
    

    As @anderly assumed, the result will be that the table will be created in the default schema of the user in the connection string.

    By the same token, at runtime, the implementation of the SafeUserTableName method results in the entire contents of the UserTableName parameter being interpreted as a table name - in the default schema.

    SimpleMembershipProvider therefore requires the user table to be in the default schema.

提交回复
热议问题