【发布时间】:2017-01-22 11:50:43
【问题描述】:
我使用 ASP.NET MVC 5 和 Entity Framework 6。所以我在 *.tt 下生成了一些文件
我想保留我插入到这些文件中的属性,因为我已经基于实体框架类自动创建了许多页面。
但是当我从数据库更新实体框架模型时,我丢失了我插入的所有内容。
所以我的问题是如何防止它被删除?
//--------------------------------------------- --------------------------------- // // 此代码是从模板生成的。 // // 手动更改此文件可能会导致意外行为 你的申请。 // 手动更改此文件将是 如果重新生成代码,则覆盖。 // //------------------------------------------------ ------------------------------
namespace MyWebSIte.DataModel
{
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
public partial class ItemMovement
{
public System.Guid ID { get; set; }
[DataType(DataType.DateTime)] <---- I would like to keep it.
[DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}", ApplyFormatInEditMode = true)]
[Display(Name = "Fecha")]
public System.DateTime? Changed { get; set; }
【问题讨论】:
标签: c# .net entity-framework asp.net-mvc-5