我正在尝试使用SQLite.Net和SQLiteNetExtensions设置一个SQLite数据库。我似乎无法在数据库中创建外键。我已经删除了所有的表,并使用模型类重新创建它们。我已经检查了SQLite管理器中的杂注,并且外键已经打开。在我的示例中,一个图可以有许多树。对我可能遗漏的内容有什么建议吗?
public class Tree
{
[PrimaryKey, AutoIncrement]
public int TreeId { get; set; }
[NotNull]
public int TreeNumber
我有两张桌子一对一的关系:
用户:
create table users (
id int not null primary key,
username varchar2(40) not null unique,
password varchar2(60) not null,
firstName varchar2(40) not null,
lastName varchar2(40) not null,
personalId varchar2(11) unique,
city varchar2(40),
address varchar2(40),
emai
如下所示,当我创建双向1:n关系时,生成器不使用任何外键(...)表上的约束。
entity customer = schema.addEntity("Customer");
customer.addIdProperty();
customer.addStringProperty("name").notNull();
Entity order = schema.addEntity("Order");
order.setTableName("ORDERS"); // "ORDER" is a reserved ke
我的用户与我的地址表有一对一的映射,它在用户表中有一个地址的外键。我想删除用户地址而不删除我的用户,但是由于我在user表中有外键,所以我无法这样做,请帮助我出。
@表(名称=“地址”)公共类地址{
@Id
@GeneratedValue
private Integer addressId;
@NotNull(message="City should not be null")
@Pattern(regexp="^[a-zA-Z]+$" ,message="City should contain only alphabets")
privat
@Entity
@Table(name = "PERSISTENCE_USER")
public class User implements Serializable {
// HERE IS A SNIPPET
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@NotNull
private String firstName;
@NotNull