【问题标题】:Files created by DbContext GeneratorDbContext Generator 创建的文件
【发布时间】:2012-03-25 02:49:27
【问题描述】:

使用 EF 4.x DbContext Generator 模板时,会创建以下文件结构:

  • Model1.Context.tt
    • Model1.Context.cs
  • 型号1.tt
    • Model1.cs
    • [实体].cs
    • ...

Model1.tt 生成实体类,如Building an MVC 3 App with Database First and Entity Framework 4.1 中所述。但是Model1.cs 的目的是什么?它没有有意义的内容:

//------------------------------------------------------------------------------
// <auto-generated>
//    This code was generated from a template.
//
//    Manual changes to this file may cause unexpected behavior in your application.
//    Manual changes to this file will be overwritten if the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

using System;
using System.Collections.Generic;

【问题讨论】:

    标签: entity-framework code-generation t4


    【解决方案1】:

    对于旧的 POCO T4 模板,此文件用于一些共享代码,例如 FixupCollection。在 DbContext T4 模板中,它可能没有真正的意义,但用于从 T4 模板生成文件的默认自定义工具以某种方式期望创建该文件(我们入侵的所有其他文件)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-04-20
      • 1970-01-01
      • 1970-01-01
      • 2022-01-20
      • 2022-10-07
      • 1970-01-01
      相关资源
      最近更新 更多