19721

Entity Framework Designer Errors

I have created a project is Visual Studio 2012 and have set up Entity framework through "Database First" approach. However after mapping to the database and generating my Designer.cs file which is supposed to be automatically generated by the framework, I end up with heaps of errors which I can't get where they come from. I have attached the error as a txt file for your review and professional comment.

Please take note that I'm new to the .net framework, specially the EF area. So I'd appreciate if you give me concrete answer so that it would help along the rest of my learning curve.

Error 1 The best overloaded method match for 'System.Data.Entity.DbContext.DbContext(string, System.Data.Entity.Infrastructure.DbCompiledModel)' has some invalid arguments C:\Users\user\Documents\TRS\TRSModel\TRSEntityModel.Designer.cs 45 32 TRSDataModel

Error 2 Argument 2: cannot convert from 'string' to 'System.Data.Entity.Infrastructure.DbCompiledModel' C:\Users\user\Documents\TRS\TRSModel\TRSEntityModel.Designer.cs 45 57 TRSDataModel

Error 3 'TRSModel.TRSEntities' does not contain a definition for 'ContextOptions' and no extension method 'ContextOptions' accepting a first argument of type 'TRSModel.TRSEntities' could be found (are you missing a using directive or an assembly reference?) C:\Users\user\Documents\TRS\TRSModel\TRSEntityModel.Designer.cs 47 18 TRSDataModel

Error 4 The best overloaded method match for 'System.Data.Entity.DbContext.DbContext(string, System.Data.Entity.Infrastructure.DbCompiledModel)' has some invalid arguments C:\Users\user\Documents\TRS\TRSModel\TRSEntityModel.Designer.cs 54 55 TRSDataModel

Error 5 Argument 2: cannot convert from 'string' to 'System.Data.Entity.Infrastructure.DbCompiledModel' C:\Users\user\Documents\TRS\TRSModel\TRSEntityModel.Designer.cs 54 78 TRSDataModel

Error 6 'TRSModel.TRSEntities' does not contain a definition for 'ContextOptions' and no extension method 'ContextOptions' accepting a first argument of type 'TRSModel.TRSEntities' could be found (are you missing a using directive or an assembly reference?) C:\Users\user\Documents\TRS\TRSModel\TRSEntityModel.Designer.cs 56 18 TRSDataModel

Error 7 The best overloaded method match for 'System.Data.Entity.DbContext.DbContext(System.Data.Common.DbConnection, bool)' has some invalid arguments C:\Users\user\Documents\TRS\TRSModel\TRSEntityModel.Designer.cs 63 59 TRSDataModel

Error 8 Argument 2: cannot convert from 'string' to 'bool' C:\Users\user\Documents\TRS\TRSModel\TRSEntityModel.Designer.cs 63 76 TRSDataModel Error 9 'TRSModel.TRSEntities' does not contain a definition for 'ContextOptions' and no extension method 'ContextOptions' accepting a first argument of type 'TRSModel.TRSEntities' could be found (are you missing a using directive or an assembly reference?) C:\Users\user\Documents\TRS\TRSModel\TRSEntityModel.Designer.cs 65 18 TRSDataModel

// Lines 10-17 using System; using System.ComponentModel; using System.Data.EntityClient; using System.Data.Objects; using System.Data.Objects.DataClasses; using System.Linq; using System.Runtime.Serialization; using System.Xml.Serialization; // Lines 45-47 public TRSEntities() : base("name=TRSEntities", "TRSEntities") { this.ContextOptions.LazyLoadingEnabled = true; OnContextCreated(); } // Lines 54-56 public TRSEntities(string connectionString) : base(connectionString, "TRSEntities") { this.ContextOptions.LazyLoadingEnabled = true; OnContextCreated(); } // Lines 63-65 public TRSEntities(EntityConnection connection) : base(connection, "TRSEntities") { this.ContextOptions.LazyLoadingEnabled = true; OnContextCreated(); } // Error return by adding the public class TRSEntities to where Rene suggested Error 1 Missing partial modifier on declaration of type 'TRSModel.TRSEntities'; another partial declaration of this type exists C:\Users\user\Documents\TRS\TRSModel\TRSEntityModel.Designer.cs 33 18 TRSDataModel Error 2 'TRSEntities': member names cannot be the usere as their enclosing type C:\Users\user\Documents\TRS\TRSModel\TRSEntityModel.Designer.cs 40 30 TRSDataModel

Answer1:

The problem was as I initially suspected. The extended TRSEntities class was declared in the wrong namespace and therefore could not identify the base ObjectContext class leading to TRSEntities class not being able to access the methods of this base class. This happened due to a change of EF name from "TRSModel" to "TRSEntityModel" which apparently did not register inside the ER engine, hence, auto-generating this context file based on the previous namespace.

One thing that I'm still not sure is how to make this change of name sink into the EF so that it would not continue assuming the old name.

Answer2:

Use NuGet to EF6 instaler but must also install tools for VS2012 or VS2013 EF6

Recommend

  • rcharts nvd3 linechart with categorical x axis
  • How to configure karma and systemjs to run tests for angular ES6 transpiled by traceur into amd form
  • Using HTML Symbol Entities instead of the actual symbol
  • R plotting, date on x axis
  • Distance matrix in R
  • Multiple database connections with Python + Pylons + SQLAlchemy
  • How to work with RouteValues with multiple values of the same name
  • Define the file path from the file name in R
  • Scatter plot with factor on horizontal axis
  • Plot ROC curve and calculate AUC in R at specific cutoff info
  • Visual Studio: Garbled debug watch of std::string's?
  • What is the difference between running in VS 2010 and running a builded EXE?
  • Entity Framework 6 connection string dll app config
  • Converting a data frame into named object in R
  • Referring to individual variables in … with dplyr quos
  • Is there a plural issue for models database context y to ies in mvc4 EF
  • Convert data type in R or Python
  • How to retrieve multiple columns from non-entity type sql query?
  • How dotnet build chooses the output name
  • Jenkins Grails plugin does not list lastest versions of Grails
  • hide missing dates from x-axis ggplot2
  • Autofac with Web API 2 - Parameter-less constructor error
  • CakePHP ACL tutorial initDB function warnings
  • Exception “firebase.functions() takes … no argument …” when specifying a region for a Cloud Function
  • Using variable in a value field in jMeter
  • Illegal mix of collations for operation for date/time comparison
  • How to make a tree having multiple type of nodes and each node can have multiple child nodes in java
  • MySQL WHERE-condition in procedure ignored
  • Cassandra Data Model
  • Numpy divide by zero. Why?
  • AT Commands to Send SMS not working in Windows 8.1
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • Codeigniter doesn't let me update entry, because some fields must be unique
  • Authorize attributes not working in MVC 4
  • apache spark aggregate function using min value
  • Busy indicator not showing up in wpf window [duplicate]
  • Sorting a 2D array using the second column C++
  • How to get NHibernate ISession to cache entity not retrieved by primary key
  • Python/Django TangoWithDjango Models and Databases
  • Net Present Value in Excel for Grouped Recurring CF