简体   繁体   中英

Entity Framework DbContext code generation generates incorrect code

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM