Null Reference
Null Reference

Reputation: 11360

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.

Upvotes: 0

Views: 1378

Answers (1)

Joel Martinez
Joel Martinez

Reputation: 47809

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

Upvotes: 2

Related Questions