没有主键的实体的Symfony原则模型 [英] Symfony Doctrine Models for Entity Without Primary Keys

查看:154
本文介绍了没有主键的实体的Symfony原则模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在重新构建Web应用程序时,我正在使用遗留数据库。我想使用Symfony2.x,显然这里有Doctrine作为ORM。我有大约50个(mysql)表没有主键。当我尝试生成模型时,它不会让我做,并用No Primary Key on ... table抛出异常。



我是否必须在桌子上使用主键才能使用Doctrine?有没有办法?



任何帮助会很棒



谢谢。

解决方案

原则要求每个实体类都有标识符/主键。



查看此页面: http://www.doctrine-project.org/docs/orm/2.0/en/reference/basic-mapping.html#标识符 - 主键


I'm working with a legacy database while re-building the web application. I want to use Symfony2.x which obviously has Doctrine as ORM.

I've around 50 (mysql) tables which has NO Primary Keys. When I try to generate models, it does not let me do and throw an exception with "No Primary Key on ... table".

Do I must have Primary Keys on tables to use Doctrine or is there any way around it?

Any help would be great.

Thanks.

解决方案

Doctrine requires every entity class to have an identifier/primary key.

Take a look at this page: http://www.doctrine-project.org/docs/orm/2.0/en/reference/basic-mapping.html#identifiers-primary-keys

这篇关于没有主键的实体的Symfony原则模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆