This project used a multi-database, when using MySQL, there are some small problems:
MySQL ERROR 1071 (42000): Specified key was too long; Max key length is 767 byte mysql.net
This problem is related to the MySQL data format, MySQL's default character set is Latin1, I have changed to UTF8 after the problem, and then a colleague told me the solution to this problem:
Set the length of the field to within 767byte by using data Annotation or the fluent API.
Specific methods:
1. Data Annotation
public class Store { [Key] [Column (TypeName = ' char ')] [MaxLength (]) public string StoreID {Set ; Get } [Column (TypeName = "char")] [MaxLength] public string Name {set; get;} public string ProductID {set; get;} Public virtual product product {set; get;} }
2. Fluent API
Modelbuilder.complextype<metadatasubject> (). Property (P = p.name). Hascolumntype ("varchar"). Hasmaxlength (50);
or by
public class metadatasubjectconfiguraiton:complextypeconfiguration<metadatasubject> { public Metadatasubjectconfiguraiton () {this . Property (P = p.name). Hascolumntype ("varchar"). Hasmaxlength (); } }
and add the set of file settings for the responsible type in the configuration function.
The basic problems can be solved by both approaches. As for many places on the web mentioned the change character set ... I can only say: hehe ...
About multi-database usage for entityframework