Reputation: 3795
This is kind of a noob question, and I am actually a bit embarassed to have not been able to figure it out myself , who knew transition from LinqToSQL to EF will be fraught with nuances like this.
Basically all I did was
1> create a MusicStore SQL database using visual studio 2012 Server Explorer with only one table.
2> Then I added a new ADO.Net Entity Data Model
edmx
and generated it using the wizard pointing to my database in step 1.
This gave me a diagram of MusicStore table. Now if I change Code Generation Strategy
in the properties to Default
instead of none
, then this is the code that is generated in the MusicStoreModel.Designer.cs
.
However, at
public MusicStoreEntities() : base("name=MusicStoreEntities", "MusicStoreEntities")
I get the has some invalid arguments
.
What am I missing here? a reference? Any help greatly appreciated.
public partial class MusicStoreEntities : ObjectContext
{
#region Constructors
/// <summary>
/// Initializes a new MusicStoreEntities object using the connection string
///found in the 'MusicStoreEntities' section of the application
///configuration file.
/// </summary>
public MusicStoreEntities() : base("name=MusicStoreEntities", "MusicStoreEntities")
{
// Also getting a compilation error at the line below
this.ContextOptions.LazyLoadingEnabled = true;
OnContextCreated();
}
Upvotes: 1
Views: 196
Reputation: 32571
This is by design. Please refer to the following link for Microsoft's official position: Entity Framework 5 Code Generation Strategy set to DEFAULT causes errors on all properties of entities.
(...) The reason you are seeing these compile errors is because you are re-enabling the legacy code generation without disabling the new T4 based code generation. This means that two sets of classes are being generated. This page provides details on how to revert to ObjectContext code generation - http://msdn.microsoft.com/en-us/data/jj556581.
Upvotes: 1