这是我最初的 SQLite 数据库
CREATE TABLE [Categories] (
[ParentId] INT,
[Name] VARCHAR(100));
CREATE TABLE [Fees] (
[CategoryId] INT,
[Name] VARCHAR(100),
[Value] VARCHAR(50),
[Info] VARCHAR(200));
CREATE TABLE [Markups] (
[CategoryId] INT,
[UpTo] MONEY,
[Value] VARCHAR(50),
[Info] VARCHAR(200));
如果我运行DbMetal /provider:Sqlite /conn "Data Source=bms4.db3" /dbml:Model.dbml
,它将成功创建 dbml 文件。
但是如果我添加一个外键,这样
CREATE TABLE [Fees] (
[CategoryId] INT CONSTRAINT [fk_fees_categories] REFERENCES [Categories]([rowid]),
[Name] VARCHAR(100),
[Value] VARCHAR(50),
[Info] VARCHAR(200));
运行相同的命令
DbMetal /provider:Sqlite /conn "Data Source=bms4.db3" /dbml:Model.dbml
会给出这个错误:
>>> Reading schema from SQLite database
DbMetal: The given key was not present in the dictionary.
如何将外键关系引入 DBML?