映射数据库架构时出错
当我尝试使用 subsonic 3.0.0.3 数据库进行映射时,出现错误:
“正在运行转换:System.InvalidOperationException:序列包含多个匹配元素...”
我应该在哪里查找错误?
When I try to map with subsonic 3.0.0.3 database, i get error:
"Running transformation: System.InvalidOperationException: Sequence contains more than one matching element..."
Where i should look for error?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
设置@OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS,UNIQUE_CHECKS=0;
设置@OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS,FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='传统';
如果不存在则创建架构
osm2
默认字符集 cp1251 整理 cp1251_general_ci;使用osm2;
-- 表
mydb
.sw_profile
如果不存在则创建表
osm2
.sw_profile
(id
INT NOT NULL ,名称
VARCHAR(45) NOT NULL ,配置
VARCHAR(500) NOT NULL ,评论
VARCHAR(45) NULL ,主键(
id
))引擎=InnoDB;
-- 表
mydb
.sw_type
如果不存在则创建表
osm2
.sw_type
(id
INT NOT NULL,名称
VARCHAR (45) NOT NULL,ports_num
INT NOT NULL,trunc_ports VARCHAR (45) NOT NULL,
supports_dhcp
TINYINT (1) NOT NULL,主键(
id
))
引擎=创新;
-- 表
mydb
.sw
如果不存在则创建表
osm2
.sw
(id
INT NOT NULL,sn
VARCHAR (45) NULL,mac
VARCHAR (45) NOT NULL,ip
VARCHAR (45) NOT NULL,评论
VARCHAR (45) NULL,sw_profile_id
INT NOT NULL,sw_type_id
INT NOT NULL,主键(
id
),索引
fk_sw_sw_profile
(sw_profile_id
ASC),INDEX
fk_sw_sw_type1
(sw_type_id
ASC),约束
fk_sw_sw_profile
外键 (
sw_profile_id
)参考
mydb
.sw_profile
(id
)删除时不执行任何操作
更新时不采取任何行动,
约束
fk_sw_sw_type1
外键(
sw_type_id
)参考
mydb
.sw_type
(id
)删除时不执行任何操作
更新后无任何操作
)
引擎 = 创新数据库
默认字符集 = cp1251;
-- 表
mydb
.port
如果不存在则创建表
osm2
.port
(id
INT NOT NULL,名称
VARCHAR (45) NOT NULL,状态
TINYINT (1) NOT NULL,user_id
INT NULL,sw_id
INT NOT NULL,主键(
id
),INDEX
fk_port_sw1
(sw_id
ASC),约束
fk_port_sw1
外键 (
sw_id
)参考
mydb
.sw
(id
)删除时不执行任何操作
更新后无任何操作
)
引擎=创新;
-- 表
mydb
.vlan
如果不存在则创建表
osm2
.vlan
(id
INT NOT NULL,名称
VARCHAR (45) NOT NULL,标签
VARCHAR (45) NOT NULL,评论
VARCHAR (500) NULL,主键(
id
))
引擎=创新;
-- 表
mydb
.address
如果不存在则创建表
osm2
.address
(id
INT NOT NULL,名称
VARCHAR (45) NOT NULL,short_name
VARCHAR (45) NOT NULL,评论
VARCHAR (45) NULL,sw_id
INT NOT NULL,主键(
id
),INDEX
fk_address_sw1
(sw_id
ASC),约束
fk_address_sw1
外键 (
sw_id
)参考
mydb
.sw
(id
)删除时不执行任何操作
更新后无任何操作
)
引擎=创新;
-- 表
mydb
.tariff
如果不存在则创建表
osm2
.tariff
(id
INT NOT NULL,名称
VARCHAR (45) NOT NULL,价格
DOUBLE NOT NULL,速度
VARCHAR (45) NOT NULL,主键(
id
))
引擎=创新;
-- 表
mydb
.client
如果不存在则创建表
osm2
.client
(id
INT NOT NULL,utm_id
VARCHAR (45) NULL,utm_login VARCHAR (45) NULL,
ip
VARCHAR (45) NOT NULL,ip_second
VARCHAR (45) NULL,联系人
VARCHAR (500) NULL,评论
VARCHAR (500) NULL,act
VARCHAR (500) NULL,vlan_id
INT NOT NULL,address_id
INT NOT NULL,tariff_id
INT NOT NULL,主键(
id
),INDEX
fk_client_vlan1
(vlan_id
ASC),INDEX
fk_client_address1
(address_id
ASC),INDEX
fk_client_tariff1
(tariff_id
ASC),约束
fk_client_vlan1
外键 (
vlan_id
)参考
mydb
.vlan
(id
)删除时不执行任何操作
更新时不采取任何行动,
约束
fk_client_address1
外键(
address_id
)参考
mydb
.地址
(id
)删除时不执行任何操作
更新时不采取任何行动,
约束
fk_client_tariff1
外键 (
tariff_id
)参考
mydb
.tariff
(id
)删除时不执行任何操作
更新后无任何操作
)
引擎=创新;
-- 表
mydb
.port_has_vlan
如果不存在则创建表
osm2
.port_has_vlan
(port_id
INT NOT NULL,vlan_id
INT NOT NULL,主键(
port_id
、vlan_id
),INDEX
fk_port_has_vlan_port1
(port_id
ASC),索引
fk_port_has_vlan_vlan1
(vlan_id
ASC),约束
fk_port_has_vlan_port1
外键(
port_id
)参考
mydb
.port
(id
)删除时不执行任何操作
更新时不采取任何行动,
约束
fk_port_has_vlan_vlan1
外键 (
vlan_id
)参考
mydb
.vlan
(id
)删除时不执行任何操作
更新后无任何操作
)
引擎=创新;
-- 表
mydb
.request_state
如果不存在则创建表
osm2
.request_state
(id
INT NOT NULL,名称
VARCHAR (45) NOT NULL,主键(
id
))
引擎=创新;
-- 表
mydb
.request_type
如果不存在则创建表
osm2
.request_type
(id
INT NOT NULL,名称
VARCHAR (45) NOT NULL,评论
VARCHAR (500) NULL,主键(
id
))
引擎=创新;
-- 表
mydb
.request
如果不存在则创建表
osm2
.request
(id
INT NOT NULL,日期
日期时间不为空,评论
VARCHAR (500) NULL,日志
VARCHAR (500) NULL,request_state_id
INT NOT NULL,request_type_id
INT NOT NULL,client_id
INT NOT NULL,主键(
id
),INDEX
fk_request_request_state1
(request_state_id
ASC),INDEX
fk_request_request_type1
(request_type_id
ASC),INDEX
fk_request_client1
(client_id
ASC),约束
fk_request_request_state1
外键(
request_state_id
)参考
mydb
.request_state
(id
)删除时不执行任何操作
更新时不采取任何行动,
约束
fk_request_request_type1
外键(
request_type_id
)参考
mydb
.request_type
(id
)删除时不执行任何操作
更新时不采取任何行动,
约束
fk_request_client1
外键(
client_id
)参考
mydb
.client
(id
)删除时不执行任何操作
更新后无任何操作
)
引擎=创新;
-- 表
mydb
.department
如果不存在则创建表
osm2
.department
(id
INT NOT NULL,名称
VARCHAR (45) NOT NULL,评论
VARCHAR (45) NOT NULL,主键(
id
))
引擎=创新;
-- 表
mydb
.group
如果不存在则创建表
osm2
.group
(id
INT NOT NULL,名称
VARCHAR (45) NOT NULL,主键(
id
))
引擎=创新;
-- 表
mydb
.account
如果不存在则创建表
osm2
.account
(id
INT NOT NULL,登录
VARCHAR (45) NOT NULL,密码
VARCHAR (45) NOT NULL,group_id
INT NOT NULL,主键(
id
),INDEX
fk_account_group1
(group_id
ASC),约束
fk_account_group1
外键(
group_id
)参考
mydb
.group
(id
)删除时不执行任何操作
更新后无任何操作
)
引擎=创新;
-- 表
mydb
.staff
如果不存在则创建表
osm2
.staff
(id
INT NOT NULL,名称
VARCHAR (45) NOT NULL,联系人
VARCHAR (45) NOT NULL,department_id
INT NOT NULL,account_id
INT NOT NULL,主键(
id
),INDEX
fk_staff_department1
(department_id
ASC),INDEX
fk_staff_account1
(account_id
ASC),约束
fk_staff_department1
外键(
department_id
)参考
mydb
.部门
(id
)删除时不执行任何操作
更新时不采取任何行动,
约束
fk_staff_account1
外键 (
account_id
)参考
mydb
.account
(id
)删除时不执行任何操作
更新后无任何操作
)
引擎=创新;
-- 表
mydb
.fid
如果不存在则创建表
osm2
.fid
(id
INT NOT NULL,文本
VARCHAR (500) NOT NULL,评论
VARCHAR (500) NULL,主键(
id
))
引擎=创新;
-- 表
mydb
.group_has_fid
如果不存在则创建表
osm2
.group_has_fid
(group_id
INT NOT NULL,fid_id INT NOT NULL,
主键(
group_id
、fid_id
),INDEX
fk_group_has_fid_group1
(group_id
ASC),索引
fk_group_has_fid_fid1
(fid_id
ASC),约束
fk_group_has_fid_group1
外键(
group_id
)参考
mydb
.group
(id
)删除时不执行任何操作
更新时不采取任何行动,
约束
fk_group_has_fid_fid1
外键 (
fid_id
)参考
mydb
.fid
(id
)删除时不执行任何操作
更新后无任何操作
)
引擎=创新;
设置 SQL_MODE=@OLD_SQL_MODE;
设置 FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
设置UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL';
CREATE SCHEMA IF NOT EXISTS
osm2
DEFAULT CHARACTER SET cp1251 COLLATE cp1251_general_ci;USE
osm2
;-- Table
mydb
.sw_profile
CREATE TABLE IF NOT EXISTS
osm2
.sw_profile
(id
INT NOT NULL ,name
VARCHAR(45) NOT NULL ,configuration
VARCHAR(500) NOT NULL ,comments
VARCHAR(45) NULL ,PRIMARY KEY (
id
) )ENGINE = InnoDB;
-- Table
mydb
.sw_type
CREATE TABLE IF NOT EXISTS
osm2
.sw_type
(id
INT NOT NULL,name
VARCHAR (45) NOT NULL,ports_num
INT NOT NULL,trunc_ports
VARCHAR (45) NOT NULL,supports_dhcp
TINYINT (1) NOT NULL,PRIMARY KEY (
id
))
ENGINE = INNODB;
-- Table
mydb
.sw
CREATE TABLE IF NOT EXISTS
osm2
.sw
(id
INT NOT NULL,sn
VARCHAR (45) NULL,mac
VARCHAR (45) NOT NULL,ip
VARCHAR (45) NOT NULL,comments
VARCHAR (45) NULL,sw_profile_id
INT NOT NULL,sw_type_id
INT NOT NULL,PRIMARY KEY (
id
),INDEX
fk_sw_sw_profile
(sw_profile_id
ASC),INDEX
fk_sw_sw_type1
(sw_type_id
ASC),CONSTRAINT
fk_sw_sw_profile
FOREIGN KEY (
sw_profile_id
)REFERENCES
mydb
.sw_profile
(id
)ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT
fk_sw_sw_type1
FOREIGN KEY (
sw_type_id
)REFERENCES
mydb
.sw_type
(id
)ON DELETE NO ACTION
ON UPDATE NO ACTION
)
ENGINE = INNODB
DEFAULT CHARACTER SET = cp1251;
-- Table
mydb
.port
CREATE TABLE IF NOT EXISTS
osm2
.port
(id
INT NOT NULL,name
VARCHAR (45) NOT NULL,state
TINYINT (1) NOT NULL,user_id
INT NULL,sw_id
INT NOT NULL,PRIMARY KEY (
id
),INDEX
fk_port_sw1
(sw_id
ASC),CONSTRAINT
fk_port_sw1
FOREIGN KEY (
sw_id
)REFERENCES
mydb
.sw
(id
)ON DELETE NO ACTION
ON UPDATE NO ACTION
)
ENGINE = INNODB;
-- Table
mydb
.vlan
CREATE TABLE IF NOT EXISTS
osm2
.vlan
(id
INT NOT NULL,name
VARCHAR (45) NOT NULL,tag
VARCHAR (45) NOT NULL,comments
VARCHAR (500) NULL,PRIMARY KEY (
id
))
ENGINE = INNODB;
-- Table
mydb
.address
CREATE TABLE IF NOT EXISTS
osm2
.address
(id
INT NOT NULL,name
VARCHAR (45) NOT NULL,short_name
VARCHAR (45) NOT NULL,comments
VARCHAR (45) NULL,sw_id
INT NOT NULL,PRIMARY KEY (
id
),INDEX
fk_address_sw1
(sw_id
ASC),CONSTRAINT
fk_address_sw1
FOREIGN KEY (
sw_id
)REFERENCES
mydb
.sw
(id
)ON DELETE NO ACTION
ON UPDATE NO ACTION
)
ENGINE = INNODB;
-- Table
mydb
.tariff
CREATE TABLE IF NOT EXISTS
osm2
.tariff
(id
INT NOT NULL,name
VARCHAR (45) NOT NULL,price
DOUBLE NOT NULL,speed
VARCHAR (45) NOT NULL,PRIMARY KEY (
id
))
ENGINE = INNODB;
-- Table
mydb
.client
CREATE TABLE IF NOT EXISTS
osm2
.client
(id
INT NOT NULL,utm_id
VARCHAR (45) NULL,utm_login
VARCHAR (45) NULL,ip
VARCHAR (45) NOT NULL,ip_second
VARCHAR (45) NULL,contacts
VARCHAR (500) NULL,comments
VARCHAR (500) NULL,act
VARCHAR (500) NULL,vlan_id
INT NOT NULL,address_id
INT NOT NULL,tariff_id
INT NOT NULL,PRIMARY KEY (
id
),INDEX
fk_client_vlan1
(vlan_id
ASC),INDEX
fk_client_address1
(address_id
ASC),INDEX
fk_client_tariff1
(tariff_id
ASC),CONSTRAINT
fk_client_vlan1
FOREIGN KEY (
vlan_id
)REFERENCES
mydb
.vlan
(id
)ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT
fk_client_address1
FOREIGN KEY (
address_id
)REFERENCES
mydb
.address
(id
)ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT
fk_client_tariff1
FOREIGN KEY (
tariff_id
)REFERENCES
mydb
.tariff
(id
)ON DELETE NO ACTION
ON UPDATE NO ACTION
)
ENGINE = INNODB;
-- Table
mydb
.port_has_vlan
CREATE TABLE IF NOT EXISTS
osm2
.port_has_vlan
(port_id
INT NOT NULL,vlan_id
INT NOT NULL,PRIMARY KEY (
port_id
,vlan_id
),INDEX
fk_port_has_vlan_port1
(port_id
ASC),INDEX
fk_port_has_vlan_vlan1
(vlan_id
ASC),CONSTRAINT
fk_port_has_vlan_port1
FOREIGN KEY (
port_id
)REFERENCES
mydb
.port
(id
)ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT
fk_port_has_vlan_vlan1
FOREIGN KEY (
vlan_id
)REFERENCES
mydb
.vlan
(id
)ON DELETE NO ACTION
ON UPDATE NO ACTION
)
ENGINE = INNODB;
-- Table
mydb
.request_state
CREATE TABLE IF NOT EXISTS
osm2
.request_state
(id
INT NOT NULL,name
VARCHAR (45) NOT NULL,PRIMARY KEY (
id
))
ENGINE = INNODB;
-- Table
mydb
.request_type
CREATE TABLE IF NOT EXISTS
osm2
.request_type
(id
INT NOT NULL,name
VARCHAR (45) NOT NULL,comments
VARCHAR (500) NULL,PRIMARY KEY (
id
))
ENGINE = INNODB;
-- Table
mydb
.request
CREATE TABLE IF NOT EXISTS
osm2
.request
(id
INT NOT NULL,date
DATETIME NOT NULL,comments
VARCHAR (500) NULL,log
VARCHAR (500) NULL,request_state_id
INT NOT NULL,request_type_id
INT NOT NULL,client_id
INT NOT NULL,PRIMARY KEY (
id
),INDEX
fk_request_request_state1
(request_state_id
ASC),INDEX
fk_request_request_type1
(request_type_id
ASC),INDEX
fk_request_client1
(client_id
ASC),CONSTRAINT
fk_request_request_state1
FOREIGN KEY (
request_state_id
)REFERENCES
mydb
.request_state
(id
)ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT
fk_request_request_type1
FOREIGN KEY (
request_type_id
)REFERENCES
mydb
.request_type
(id
)ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT
fk_request_client1
FOREIGN KEY (
client_id
)REFERENCES
mydb
.client
(id
)ON DELETE NO ACTION
ON UPDATE NO ACTION
)
ENGINE = INNODB;
-- Table
mydb
.department
CREATE TABLE IF NOT EXISTS
osm2
.department
(id
INT NOT NULL,name
VARCHAR (45) NOT NULL,comments
VARCHAR (45) NOT NULL,PRIMARY KEY (
id
))
ENGINE = INNODB;
-- Table
mydb
.group
CREATE TABLE IF NOT EXISTS
osm2
.group
(id
INT NOT NULL,name
VARCHAR (45) NOT NULL,PRIMARY KEY (
id
))
ENGINE = INNODB;
-- Table
mydb
.account
CREATE TABLE IF NOT EXISTS
osm2
.account
(id
INT NOT NULL,login
VARCHAR (45) NOT NULL,password
VARCHAR (45) NOT NULL,group_id
INT NOT NULL,PRIMARY KEY (
id
),INDEX
fk_account_group1
(group_id
ASC),CONSTRAINT
fk_account_group1
FOREIGN KEY (
group_id
)REFERENCES
mydb
.group
(id
)ON DELETE NO ACTION
ON UPDATE NO ACTION
)
ENGINE = INNODB;
-- Table
mydb
.staff
CREATE TABLE IF NOT EXISTS
osm2
.staff
(id
INT NOT NULL,name
VARCHAR (45) NOT NULL,contacts
VARCHAR (45) NOT NULL,department_id
INT NOT NULL,account_id
INT NOT NULL,PRIMARY KEY (
id
),INDEX
fk_staff_department1
(department_id
ASC),INDEX
fk_staff_account1
(account_id
ASC),CONSTRAINT
fk_staff_department1
FOREIGN KEY (
department_id
)REFERENCES
mydb
.department
(id
)ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT
fk_staff_account1
FOREIGN KEY (
account_id
)REFERENCES
mydb
.account
(id
)ON DELETE NO ACTION
ON UPDATE NO ACTION
)
ENGINE = INNODB;
-- Table
mydb
.fid
CREATE TABLE IF NOT EXISTS
osm2
.fid
(id
INT NOT NULL,text
VARCHAR (500) NOT NULL,comments
VARCHAR (500) NULL,PRIMARY KEY (
id
))
ENGINE = INNODB;
-- Table
mydb
.group_has_fid
CREATE TABLE IF NOT EXISTS
osm2
.group_has_fid
(group_id
INT NOT NULL,fid_id
INT NOT NULL,PRIMARY KEY (
group_id
,fid_id
),INDEX
fk_group_has_fid_group1
(group_id
ASC),INDEX
fk_group_has_fid_fid1
(fid_id
ASC),CONSTRAINT
fk_group_has_fid_group1
FOREIGN KEY (
group_id
)REFERENCES
mydb
.group
(id
)ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT
fk_group_has_fid_fid1
FOREIGN KEY (
fid_id
)REFERENCES
mydb
.fid
(id
)ON DELETE NO ACTION
ON UPDATE NO ACTION
)
ENGINE = INNODB;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
看来我发现了问题。
在我的架构中,有一些表有 2 个带有属性主键的字段(通过该表使用多对多连接)。
这是错误吗?
It looks like I found problem.
There are some tables with 2 fields with property primary key (through this tables uses connection many to many) in my schema.
Is it bug?