Reputation: 534
I have few entities [tables] with DbGeography
[geography] columns and one stored procedure that uses ObjectParameter
and IObjectContextAdapter
.
Each time I update EDMX model from database, I need to rewrite:
//for each geography column
public System.Data.Spatial.DbGeography geoColum
//for class where stored procedure is generated
using System.Data.Objects;
using System.Data.Objects.DataClasses;
to
//for each geography column
public System.Data.Entity.Spatial.DbGeography geoColum
//for class where stored procedure is generated
using System.Data.Entity.Core.Objects;
using System.Data.Entity.Core.Objects.DataClasses;
in my project, because it doesn't compile with classes generated by EF.
Why EF 6 still generating this wrong? How can I force EF to generate correct paths?
Upvotes: 1
Views: 278
Reputation: 34285
You're still using code generation from the old version of Entity Framework. Make sure you have correctly updated the project to EF6.
If you have any models created with the EF Designer, you will need to update the code generation templates to generate EF6 compatible code.
Note: There are currently only EF 6.x DbContext Generator templates available for Visual Studio 2012 and 2013.
Delete existing code-generation templates. These files will typically be named
<edmx_file_name>.tt
and<edmx_file_name>.Context.tt
and be nested under your edmx file in Solution Explorer. You can select the templates in Solution Explorer and press the Del key to delete them.Note: In Web Site projects the templates will not be nested under your edmx file, but listed alongside it in Solution Explorer.
Note: In VB.NET projects you will need to enable 'Show All Files' to be able to see the nested template files.
Add the appropriate EF 6.x code generation template. Open your model in the EF Designer, right-click on the design surface and select Add Code Generation Item...
If you are using the DbContext API (recommended) then EF 6.x DbContext Generator will be available under the Data tab.
Note: If you are using Visual Studio 2012, you will need to install the EF 6 Tools to have this template. See Get Entity Framework for details.
If you are using the ObjectContext API then you will need to select the Online tab and search for EF 6.x EntityObject Generator.
If you applied any customizations to the code generation templates you will need to re-apply them to the updated templates.
See Upgrading to EF6 for more details.
Upvotes: 2