System.InvalidOperationException: "The model backing the 'Connection' context has changed since the database was created
Мне нужно, что бы при регистрации каждого нового пользователя, создавалась таблица, которая бы называлась как логин пользователя
public class Connection : DbContext
{
public string CurrentLogin { get; set; }
public Connection() : base("LinkConnectionString")
{
}
public DbSet<User> Users { get; set; }
public DbSet<Word> Words { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Entity<Word>().ToTable(CurrentLogin);
}
}
Выдает ошибку
System.InvalidOperationException: "The model backing the 'Connection' context has changed since the database was created. Consider using Code First Migrations to update the database (http://go.microsoft.com/fwlink/?LinkId=238269)."
на строке
connection.Users.Add(user);
string loginString = LoginEnter.Text;
string passwordString = PasswordEnter.Text;
using (Connection connection = new Connection())
{
connection.CurrentLogin = loginString;
User user = new User()
{
Login = loginString,
Password = passwordString
};
connection.Users.Add(user);
connection.SaveChanges();
}