[英]ASP.NET Azure MySQL code first migrations: Table 'xxx' already exists
I have this frustrating problem when trying to enable code migrations to create DB schema on azure MySql DB i got the: 当尝试启用代码迁移以在蔚蓝的MySql DB上创建数据库架构时,我遇到了一个令人沮丧的问题,我得到了:
[DbConfigurationType(typeof(MySqlEFConfiguration))]
specified to my data context and also 指定给我的数据上下文
var configuration = new App.Migrations.Configuration();
var migrator = new DbMigrator(configuration);
migrator.Update();
but a simple Table that contains only ID property and a String doesnt seem to work on Azure, it says Table 'xxx' already exists, and when it doesnt it gives another error saying Specified key was too long; 但是一个仅包含ID属性和字符串的简单表在Azure上似乎不起作用,它说表'xxx'已经存在,当它不存在时,它又给出另一个错误,指出指定键太长; max key length is 767 bytes
最大密钥长度为767字节
whats wrong with the MySQL and Code First schema generation? MySQL和Code First模式生成有什么问题? thanks
谢谢
Issue is likely... 问题可能...
I would recommend opening the Visual Studio 2015 SQL Server Object explorer and running a few queries on the tables in question or just see if those tables exist and what data is in them. 我建议您打开Visual Studio 2015 SQL Server对象资源管理器,并对有问题的表运行一些查询,或者只是看看这些表是否存在以及其中包含哪些数据。
I also do not like code first migrations, for these sorts of reasons. 由于种种原因,我也不喜欢代码优先迁移。 I would recommend following this tutorial series.
我建议遵循本教程系列。
https://channel9.msdn.com/Blogs/Have-you-tried-turning-it-off-and-on-again/Creating-a-Database-Project-for-Artificial-Intelligence https://channel9.msdn.com/Blogs/Have-you-tried-turning-it-off-and-on-again/Creating-a-Database-Project-for-Artificial-Intelligence
https://channel9.msdn.com/Blogs/Have-you-tried-turning-it-off-and-on-again/Deploying-Database-Projects-to-SQL-Azure https://channel9.msdn.com/Blogs/Have-you-tried-turning-it-off-and-on-again/Deploying-Database-Projects-to-SQL-Azure
https://channel9.msdn.com/Blogs/raw-tech/AI-Part-3-Entity-Framework-and-Unit-Tests https://channel9.msdn.com/Blogs/raw-tech/AI-Part-3-Entity-Framework-and-Unit-Tests
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.