1. The model backing the ' musicstoredbcontext ' context has changed since the database was created.
Consider using Code first migrations to update the database
Movie This table is used to record the model version number, each time you regenerate the database it will re-assign a new value to the Modelhash column.
is different from the original database.
2. Automatically change the table name of the database to a complex number, resulting in an error
Method One: Use Tableattribute to specify the mapped table name for the entity class
1[Table ("User")]2 Public classUser3 {4 [Key]5 Public intId {Get;Set; }6 Public stringUSN {Get;Set; }7 Public stringPWD {Get;Set; }8 PublicDateTime Created {Get;Set; }9}
View Code
Method Two: Overriding the Onmodelcreating method does not allow you to change the table name to a plural form
Public classusercontext:dbcontext{ PublicUserContext ():Base("Name=sqlserver") { } protected Override voidonmodelcreating (Dbmodelbuilder modelBuilder) {modelBuilder.Conventions.Remove<System.Data.Entity.ModelConfiguration.Conventions.PluralizingTableNameConvention>(); } PublicDbset<user> User {Get;Set; }}
View Code
Frequently asked questions in MVC