将实体框架与 MyIsam 表结合使用
有关于实体框架和 MyIsam 表的问题。
我的生产数据库仅包含 MyIsam 表。通常使用像 UserId 这样的主键,然后使用自动增量的辅助 KeyId。
由于 InnoDb 中不允许使用辅助自动增量键,并且在转换之前需要做大量工作来删除它们,因此我正在考虑将 MyIsam 表与实体框架一起使用。
问题是,我该如何设置呢?如果没有外键,则将表添加到 EF 模型时不会有任何关系。我尝试过手动添加关联,但总是出现一些错误。当使用辅助自动增量键时这是否可能?
如果有人能尝试帮助我,我将非常感激。
谢谢
/安德烈亚斯
Got a question about Entity Framework and MyIsam tables.
My production database consists of MyIsam tables only. Often with a primary key like UserId and then a secondary KeyId that is auto incrementary.
Since secondary auto incremantary keys are not allowed in InnoDb, and there will be ALOT of work to get rid of them before converting, I'm thinking about using MyIsam tables with Entity Framework instead.
The question is, how do I set up this? With no foreign keys there will be no relationships when adding the tables to the EF model. I've tried adding the associations manually but always with some errors. Is this even possible when using a secondary auto increment key?
I would be very grateful if someone could try helping me.
Thanks
/Andreas
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
显然这并不难。我想我误解了如何使用引用约束。
无论如何,为了将来的参考和发现这个问题的人们:
只需在实体之间添加关联,然后使用所需的实体键添加引用约束,甚至无需考虑辅助自动增量键。反正一切顺利..
Apparantly this wasn't hard at all. I think i misunderstood how to use referential constraints.
Anyway, for future reference and people finding this question:
Just add an association between the entities and then add a referential constraint using the desired entity keys, without even thinking about the secondary auto increment key. It all works out anyway..