I have a model:
User
public class User {
public int Id { get; set; }
public string UserName {get; set;}
...
public int? ManagerId {get; set;}
public User Manager {get; set;}
public int? SupervisorId {get; set;}
public User Supervisor {get; set;}
..
}
I have checked my MySQL Db, and found that ManagerId is unique. I didn't set it as unique. Now i want to remove that using dotnet ef migrations. How to do that ?
I use donet core 2.1 at the moment.
I have test with remove the ManagerID and Manager and do dotnet ef migrations add UpdateUser
checked and ManagerID is removed. then I tried to add again new name AssignedManagerID and it created new one with unique is true.
migrationBuilder.CreateIndex(
name: "IX_Users_AssignedManagerId",
table: "Users",
column: "AssignedManagerId",
unique: true);
my Datacontext: public DbSet Users {get; set;}
I have no Fluent at all on OnModelCreating() for User
Id
field is counted as unique, did you changed your model after applying migrations?[Index(IsUnique=false)]
? or fluent one? learn.microsoft.com/en-us/ef/core/modeling/…