-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
how to change the identity table name and then customize user and role #2
Comments
I can't look at this right now, as I am out the door to work. However, if you change the name of a table (or any of the column names involved in Primary Keys/Foreign Keys, I believe you need to do some additional mapping so that EF knows how things relate. The existing DB entities are mapped to eachother based on convention. You have introduced a new table, and EF has no way to know how it fits in the scheme of things, so it does the best it can based on your model. You will likely need to do something like I did when mapping two new tables into the database for the Group-Based Permisssions project. |
Dear Sir, On Mon, Dec 1, 2014 at 6:30 PM, John Atten [email protected] wrote:
|
Dear john Atten,
On Tue, Dec 2, 2014 at 10:34 AM, Rakibul Islam [email protected]
|
In exactly similar scenario, I am getting following error: Thanks in advance!! |
Yeah, things have changed since the article was written. If any one wants to me the changes and shoot me a PR, I would be forever grateful :-) |
Following is the code snippet, I have my existing User table from existing database and don't want roles and claim etx, Just username password authentication, So I've put ignore for everything I dont want, and I am getting above error: modelBuilder.Entity()
Error: The model backing the 'ApplicationDbContext' context has changed since the database was created. Consider using Code First Migrations to update the database |
I follow your AspNet-Identity-2-Extending-Users-And-Roles tutorial and it working fine .But i wanted to change my Identity table name.I wrote the code as below
public class ApplicationDbContext : IdentityDbContext
{
public ApplicationDbContext()
: base("DefaultConnection")
{
it changes identity table name.but create a problem in userroles table an extra column added [IdentityUser_Id] NVARCHAR (128) NULL, and when i add user and user role no data added in this field .and [authorize(Role="Admin,User")] always return log in page .how can it solved ?please give suggession? the userroles table script is below:
CREATE TABLE [dbo].[userrole]([UserId] NVARCHAR %28128%29 NOT NULL,
[RoleId] NVARCHAR %28128%29 NOT NULL,
[IdentityUser_Id] NVARCHAR %28128%29 NULL,
CONSTRAINT [PK_dbo.userrole] PRIMARY KEY CLUSTERED %28[UserId] ASC, [RoleId] ASC%29,
CONSTRAINT [FK_dbo.userrole_dbo.mcms_role_RoleId] FOREIGN KEY %28[RoleId]%29 REFERENCES [dbo].[role] %28[Role_ID]%29 ON DELETE CASCADE,
CONSTRAINT [FK_dbo.mcms_userrole_dbo.mcms_user_IdentityUser_Id] FOREIGN KEY %28[IdentityUser_Id]%29 REFERENCES [dbo].[user] %28[User_ID]%29);
The text was updated successfully, but these errors were encountered: