I'm getting this exception:
The model backing the 'database' context has changed since the database was created. Consider using Code First Migrations to update the database (http://go.microsoft.com/fwlink/?LinkId=238269).
As I have been told, that error comes when you change you model that represents the tables of you database and your database have not the same attributes(tables and fields)(correct me if I'm wrong).
Tbl_Users, which is in the database, has the following structure
dbUser(int,not null)//key
dbUserId(varchar(50),null)//allow null, right?
dbPassWord(varchar(20),null)
This is the model:
public class Tbl_Users {
[Key,DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int dbUser { get; set; }
[MaxLength(50)]
public string dbPassWord { get; set; }
[MaxLength(20)]
public string dbUserID{ get; set; }
public int? dbLock { get; set; }
}
How can I set public string dbPassWord { get; set; } and public string dbPassWord { get; set; } to allow nulls?
Or is there any other solution for this error?
Update
If I add a migration, and I update the database with Update-Database as told here, will the values of the affected table be erased?
dbPassWord. Aside from the odd capitalization of bothdandw, you can't declare two properties with the same name. And then there's the lack ofdbUserIdin your property list, and the lack ofdbLockin your model...string?as an example.stringis already nullable as it's a reference type.