0

我有一个大数据库,它由两部分组成:后台和前端部分。后台部分永远不会因项目而改变,因此他们有自己的业务和数据组件。

数据层有它自己的代码迁移,它自己DbContext称为BackofficeContext. 架构是Backoffice

前端具有相同的结构,也有自己的数据层、自己的代码迁移和DbContext调用的FrontendContext. 这有不同的架构Frontend

在数据库中,我将看到 Backoffice 和 Frontend 相关表的清晰分离,这正是我想要的。

只有一个问题。中的一个表FrontendContext包含一个字段BackofficeContext

public class UserChoise
{
    [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
    public Guid UserChoiseId { get; set; }

    [Required]
    public Guid UserId { get; set; }

    [ForeignKey("UserId")]
    public User User { get; set; }

    ....
}

用户表在 中BackofficeContextUserChoises表在 中FrontendContext

当我为 运行代码迁移时,BackofficeContext它将为Users. 当我为它运行代码迁移时,FrontendContext它会创建UserChoises表,但也会再次创建Users表。

我可以从迁移文件中手动删除此表,但每次进行新迁移时它都会返回。

有没有办法让人们FrontendContext意识到BackofficeContext

4

0 回答 0