I generated an EDMX from a MySQL database and can see the related Context.tt and .tt files (that generate the Model class and Data context class.
When I right-click on Controllers and select Add Controller I enter the controller name then for template I select
MVC controller with read/write actions and views, using Entity Framework.
I can't see the classes generated by the TT files in the drop-downs for
Model class: or Data context class: as I'd expect to be able... instead I can only see the
Entities file relating to my DB.
How can I make it so that the TT generated model class and data context class are available in the drop-down?
...or is there some other way I'm supposed to generate a Controller relating to this EDMX?
Make sure to build the application after genertaing the file.
"And whoever is removed away from the Fire and admitted to Paradise, he indeed is successful." (The Holy Quran)
Excellent Windows VPS Hosting Imran Baloch MVP, MVB, MCP, MCTS, MCPD
Make sure to build the application after genertaing the file.
I did build the application after generating the file.
Just to be sure I did a clean and rebuild on the solution. Since I still only have the dbEntities class available in the dialog, I chose that for both the model class and context class. Maybe the error from that will give a hint:
'Project.Models.dbEntities' is not part of the specified
'Project.Models.dbEntities' class, and the
'Project.Models.dbEntities' class could not be modified to add a
'DbSet<Project.Models.dbEntities>' property to it. (For example, the
'Project.Models.dbEntities' class might be in a compiled assembly.)
If I add additional code generation items Figure 5, then on subsequent compiles I get an error that
Project.Models.dbEntities already defines a member called 'dbEntities' with the same parameter types
This proves that the appropriate TT's were already generated.
So I created a controller and in the Index() method I added the following lines:
dbEntities db = new dbEntities();
db.TableName...
And I'm not getting any autocomplete. When I connect to the DB via server explorer I can see that the TableName table exists and contains data. So something about this EDMX wireup is not right.
And I'm not getting any autocomplete. When I connect to the DB via server explorer I can see that the TableName table exists and contains data. So something about this EDMX wireup is not right.
Recreating the Edmx might be work. On a new Project I have not found any issue.
"And whoever is removed away from the Fire and admitted to Paradise, he indeed is successful." (The Holy Quran)
Excellent Windows VPS Hosting Imran Baloch MVP, MVB, MCP, MCTS, MCPD
Marked as answer by Bleak Morn on Sep 24, 2012 03:13 PM
Bleak Morn
Member
29 Points
60 Posts
Snag Creating Controller in MVC4 with DB Generated .EDMX
Sep 23, 2012 04:25 AM|LINK
I generated an EDMX from a MySQL database and can see the related Context.tt and .tt files (that generate the Model class and Data context class.
When I right-click on Controllers and select Add Controller I enter the controller name then for template I select MVC controller with read/write actions and views, using Entity Framework.
I can't see the classes generated by the TT files in the drop-downs for Model class: or Data context class: as I'd expect to be able... instead I can only see the Entities file relating to my DB.
How can I make it so that the TT generated model class and data context class are available in the drop-down?
...or is there some other way I'm supposed to generate a Controller relating to this EDMX?
imran_ku07
All-Star
45815 Points
7698 Posts
MVP
Re: Snag Creating Controller in MVC4 with DB Generated .EDMX
Sep 23, 2012 06:46 PM|LINK
Make sure to build the application after genertaing the file.
Excellent Windows VPS Hosting
Imran Baloch MVP, MVB, MCP, MCTS, MCPD
Bleak Morn
Member
29 Points
60 Posts
Re: Snag Creating Controller in MVC4 with DB Generated .EDMX
Sep 24, 2012 10:55 AM|LINK
I did build the application after generating the file.
Just to be sure I did a clean and rebuild on the solution. Since I still only have the dbEntities class available in the dialog, I chose that for both the model class and context class. Maybe the error from that will give a hint:
'Project.Models.dbEntities' is not part of the specified
'Project.Models.dbEntities' class, and the
'Project.Models.dbEntities' class could not be modified to add a
'DbSet<Project.Models.dbEntities>' property to it. (For example, the
'Project.Models.dbEntities' class might be in a compiled assembly.)
As a troubleshooting guide, I've been following along with this example:
http://msdn.microsoft.com/en-us/data/gg685489
If I add additional code generation items Figure 5, then on subsequent compiles I get an error that Project.Models.dbEntities already defines a member called 'dbEntities' with the same parameter types
This proves that the appropriate TT's were already generated.
So I created a controller and in the Index() method I added the following lines:
dbEntities db = new dbEntities();
db.TableName...
And I'm not getting any autocomplete. When I connect to the DB via server explorer I can see that the TableName table exists and contains data. So something about this EDMX wireup is not right.
imran_ku07
All-Star
45815 Points
7698 Posts
MVP
Re: Snag Creating Controller in MVC4 with DB Generated .EDMX
Sep 24, 2012 02:49 PM|LINK
Recreating the Edmx might be work. On a new Project I have not found any issue.
Excellent Windows VPS Hosting
Imran Baloch MVP, MVB, MCP, MCTS, MCPD
Bleak Morn
Member
29 Points
60 Posts
Re: Snag Creating Controller in MVC4 with DB Generated .EDMX
Sep 24, 2012 03:13 PM|LINK
Yeah, I nuked the EDMX and re-created from scratch. Worked this time.