Reputation: 949
I have a DBContext driven class named OnlineShoppingContext like below:
public class OnlineShoppingContext:DbContext
{
public OnlineShoppingContext(string connectionString):base(connectionString)
{
}
public DbSet<User> Users { get; set; }
}
I use it in following code:
using (var context = new OnlineShoppingContext("ConnectionStringValue"))
{
if (context.Users.Any(item => item.Email == Email && item.Password == "pass"))
session["Username"] = Email;
}
But I receive following exception:
The model backing the 'OnlineShoppingContext' context has changed since the database was created. Consider using Code First Migrations to update the database (http://go.microsoft.com/fwlink/?LinkId=238269).
I recreate database using Delete and then CreateIfDoesNotExist method of dbcontext but again i receive mentioned exception. What I must to do?
Upvotes: 1
Views: 305
Reputation: 663
As you don't have set a DB Initializer, try using the following:
Database.SetInitializer<OnlineShoppingContext>(null);
Upvotes: 1