1. Modify or add connectionstrings
< connectionStrings > < name= "Mvcdbcontext" connectionString= "datasource=192.168.1.2;database= mvcdb;uid=root;pwd=a123456; " ProviderName = "MySql.Data.MySqlClient" /> </ connectionStrings >
2. The various errors that occur when creating a database, summarizing 2 questions!
(1) Modify MySQL's default engine to InnoDB, as follows
Modifying the MySQL my.cnf file will
Default-storage-engine=myisam change to Default-storage-engine=innodb if there is innodb=offskip-innodb in the configuration file then delete!!
(2) This problem is prompted Specified key was too long; Max key length is 767 bytes such error
// Add the following annotations to the context [Dbconfigurationtype (typeof(MySql.Data.Entity.MySqlEFConfiguration))] Public class mycontext:dbcontext{}
Then write a code to generate the database according to the code!!
New Mvcdbcontext ();d B. Database.createifnotexists (); // If you do not create one, skip db. SaveChanges ()
EF6.0 Code first uses MySQL's various errors and workarounds!!