Entity Framework DbContext code generation generates incorrect code

a 夏天 提交于 2019-12-13 05:35:33

问题


I'm using VS2010 with Entity Framework (file version is 4.4. product version is 5)

I have installed the EF5.x DbContext generator.

After creating my .edmx file, I right clicked on the empty space and added a new DbContext template, which generated the context.tt and .tt files.

However, in the .tt files, this is how the auto generated code looks like:

namespace DataObjects.EntityFramework.Models
{
    using System;
    using System.Collections.Generic;

    public partial class SubSystem
    {
        public string SubSystemId { get; set; }
        public string Description { get; set; }
        public string Fmode { get; set; }
        public Nullable<System.DateTime> LastBackup { get; set; }
    }
}

The problem is that the using statements are inside the namespace, which gives rise to a compilation error.


回答1:


Those compilation errors must be related to something else, because it's perfectly legal in C# to have using statements in the namespace.

Verify that you've added all of the correct references, such as EntityFramework.dll



来源:https://stackoverflow.com/questions/13060614/entity-framework-dbcontext-code-generation-generates-incorrect-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!