With MYSQL in ASP. NET Core, if the field type is, regardless of the length of the
varchar
set, when inserting or updating data, it will automatically truncate (intercept 255-length characters).
The cause of the problem is that the MySql.Data.EntityFrameworkCore
package was used (the version I used is 7.0.7-m6
), it could be a version issue, and the upgrade version might not be the problem.
workaround : All MySql field types are varchar
fields (field lengths greater than 255), and the type is changed text
(can be no length, default is 0).
The EF Core mapping configuration is then modified as follows:
protected override void Onmodelcreating (ModelBuilder ModelBuilder) {var entity = modelbuilder.entity<entity> (); Entity. Property (P = p.body). Hascolumntype ("text"); Add Hascolumntype ("text") base. Onmodelcreating (ModelBuilder);}
Resources: