- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我正在尝试使用 EF 代码优先和这个简单的代码创建包含 2 个表(Districts
和 Databases
)的新数据库:
using (var db = new FirebirdDBContext(_connectionString))
{
db.Database.CreateIfNotExists();
}
我的类(class):
public class District
{
[Key]
public int District_id { get; set; }
[Column(TypeName = "VARCHAR")]
[StringLength(50)]
public string District_name { get; set; }
[ForeignKey("DataBase")]
public int DataBase_id { get; set; }
public DataBase DataBase { get; set; }
}
public class DataBase
{
[Key]
public int DataBase_id { get; set; }
[Column(TypeName = "VARCHAR")]
[StringLength(50)]
public string DataBase_name { get; set; }
public ICollection<District> District { get; set; }
public DataBase()
{
District = new List<District>();
}
}
但不幸的是它抛出了一个错误:
Specified argument was out of the range of valid values.
Parameter name: The name 'FK_Districts_DataBases_DataBase_id' is longer than Firebird's 31 characters limit for object names.
我知道 Firebird 的 31 个字符限制,但如果我先使用 Entity Framework 代码,我该如何解决这个问题?
最佳答案
增加 Firebird 对元数据字段名称的 31 个字符限制一直是一个不变的功能请求,并且没有增加长度限制的真正方法。
话虽如此,我们也许能够控制 EF 试图生成的外键约束名称的长度。这将涉及将您的类属性重命名为较短的名称(但仍将它们映射到它们的真实列名字)
希望 EF 根据类的属性名称而不是实际的列生成外键约束名称。
FK_Districts_DataBases_DataBase_id 是 23 + 11 = 34 个字符。我们需要让它少于 32 个字符..
我认为这个前缀可能是不可避免的。 FK_Districts_DataBases_所以我们有 7-8 个字符后缀的余地。
试试这个:
public class District
{
[Key]
public int District_id { get; set; }
[Column(TypeName = "VARCHAR")]
[StringLength(50)]
public string District_name { get; set; }
[ForeignKey("DataBase")]
[Column("DataBase_id")]
public int DbId { get; set; } // reduce the column name
public DataBase DataBase { get; set; }
}
public class DataBase
{
[Key]
[Column("DataBase_id")]
public int DbId { get; set; } // reduce the column name
[Column(TypeName = "VARCHAR")]
[StringLength(50)]
public string DataBase_name { get; set; }
public ICollection<District> District { get; set; }
public DataBase()
{
District = new List<District>();
}
}
希望 EF 将约束名称设为“FK_Districts_DataBases_DbId”(27 个字符)
关于c# - Entity Framework 代码优先和 Firebird - 外键名称问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35789394/
我有一个关于 Firebird 客户端和服务器版本的问题。我知道由于 ODS 更改,数据库文件必须与 Firebird 服务器匹配。即 Firebird 建议在服务器版本 2.5.1 和 2.5.2
是否可以使用相同 Firebird 版本的 Firebird Embedded 打开 Firebird 数据库文件?当然,我知道我不能同时通过 FB Embedded 和 FB 打开同一个文件。但在关
首先我读到了这个问题: Firebird database replication 但我不想复制...我只想将数据库上已更改的数据添加到我们的主数据库中。有什么想法吗? 最佳答案 AFAICT 这也是
我同时使用 Firebird 嵌入式和 Firebird 服务器,有时我需要使用如下程序重新索引表: CREATE PROCEDURE MAINTENANCE_SELECTIVITY ASDECLAR
firebird 是否支持事务模式更改?在我看来,MySQL 没有(我说得对吗?)。 最佳答案 我打算发布一个简单的"is",但 Stack Overflow 不接受少于 15 个字符的答案。简而言之
我正在尝试将 Firebird 2.5.1 迁移到 Firebird 3.0 做了什么: 备份 Firebird 2.5.1 在 Firebird 3 上恢复 问题是并不是所有的表都被迁移了;过程、触
我的意思是,即使数据库为空,您也必须删除 varchar(50) 字段并重新创建它以使其成为 varchar(30)。更别说约束了…… 这是非常令人沮丧的。我是 SYSDBA,Firebird 使非常
当我尝试更改 Firebird 中不同所有者的表时,出现此错误: unsuccessful metadata update MODIFY RDB$RELATION_FIELDS failed no p
我有下表 create table LIST_PIPE_TABLE ( ID INT, ITEM VARCHAR(4000), IS_FOLDER VARCHAR
有没有一种快速的方法来列出为数据库定义的所有实际上没有被任何字段使用的 Firebird 域?我有一个包含许多表和许多域的大型数据库,似乎其中很多不再使用,所以我想是时候进行清理了! 我认为这可以通过
我有一个表 t,其中一列是 int 类型,有几行。 我想循环它。当然,我可以为此编写一个选择查询。不过我是学程序的,写了个程序, set term ^; create procedure qt ret
我正在尝试使用 FlameRobin 打开一个 .fdb (Firebird) 数据库,但它给了我以下错误消息: *** IBPP::SQLException *** Context: Databas
我有一个旧版 Firebird(版本 2.5.2)数据库,并使用 FlameRobin(版本 0.0.2.1851)来检查它。 我已在 RDB$RELATION_CONSTRAINTS 表上运行以下查
我是这里的 Firebird 新手。我正在尝试从 ASP.Net 应用程序使用 Firebird Embedded。一切都连接正常,但我遇到了列名称长度的问题。我正在尝试创建一个名为“Orchard_
刚刚开始将 Firebird 与 Delphi XE 结合使用。需要一些从客户端计算机连接到服务器的帮助。 我可以 ping 服务器,因此存在连接。但是当我从 firebird/bin 文件夹运行 i
我在 Ubuntu 中打开命令提示符,然后登录 Firebird,如下所示: $ isql-fb SQL> connect "localhost:/var/lib/firebird/2.5/data/
已下载 Firebird 数据库 Firebird-3.0.3.32900-0_x64_pdb.zip。解压文件夹install_service.bat并能够访问EMPLOYEE.FDB数据库。无需
如何在 Firebird 中将多个数据库合并为一个?我尝试了 fbexport,但没有在 Ubuntu 上编译 fbexport,我不断收到此错误。 g++ -pthread -lfbclient -
我想查询以下内容:所有表及其列和数据类型 到目前为止,我从 http://www.firebirdfaq.org/faq174/ 得到了这个 select f.rdb$relation_name, f
我有一个接近 4GB 文件系统限制大小的 firebird 数据库。如何将单个数据库文件拆分为多个文件? 最佳答案 对于单个文件数据库,Firebird 数据库可以跨越数 TB。 InterBase
我是一名优秀的程序员,十分优秀!