EF DbContext如何隔离域对象并避免自动生成的代码问题

本文关键字:自动生成 问题 代码 对象 何隔离 DbContext 隔离 EF | 更新日期: 2023-09-27 18:28:50

DB上下文是在EF中自动生成的。这很好,但我该如何防止删除我的域类包含?有什么窍门吗?

namespace EFContext
{
    using xxx.DomainObjects;//<---------------------------------- here
    using System;
    using System.Data.Entity;
    using System.Data.Entity.Infrastructure;
    public partial class EFContextContainer : DbContext
// <auto-generated>
//    This code was generated from a template.

EF DbContext如何隔离域对象并避免自动生成的代码问题

在另一个文件中创建部分EFContextContainer并在其中包含命名空间。