Empty .Designer.cs file after generating .edmx using EF 4.x in ASP.Net MVC4 application

I started a very simple ASP.Net MVC4 application using the first database approach (with an existing database). I created .edmx using the Entity Data ADO.Net data model template. This process created the xxxxxxx.Designer.cs file in the xxxxxxx.edmx section. However, the .cs file is empty with the following message.

 // Default code generation is disabled for model 'C:\Visual Studio 2010\Projects\xxx\DProject\Models\BIReportDataModel.edmx'. // To enable default code generation, change the value of the 'Code Generation Strategy' designer // property to an alternate value. This property is available in the Properties Window when the model is // open in the designer. 

Following the post, I changed the properties that generated the code in the xxxxxxx.Designer.cs file.

Question:

  • Is this the right thing? What is the purpose of this file?
  • Should I also generate strongly typed DBContext classes on the .edmx designer page, by right-clicking β€œadd code generation element” and then selecting EF DBContext Generator?

What is the first database approach?

I saw a lot of posts / blogs / tutorials and everything seems very confusing and mostly for the CodeFirst approach.

+7
source share
2 answers

Code First is technically BOTH first a database, not a database (it is flexible). You just create POCO (plain old C # objects). These classes will display the structure of the database table schema the way you want, regardless of whether the database exists or not. If you do not know what you are doing, then you probably do not want to do this.

Earlier in EDMX, it was planned to populate the constructor, but in VS 2012 and above, tt files are used by default. You should use the tt editor from nuget to really benefit from them.

OR I suggest you do the following

  1. Open the EDMX file - double click 2. Right Click in the EDMX diagram and click on Properties 3. In the properties window change the "Code Generation Strategy" from None to Default 4. Delte the tt files as you don't want both entities / contexts in project. 
+7
source

In visual studio 2017, to create code in a .cs file. (using entity framework 5.0), I do:

  • Open the .edmx model and change the "code generation strategy"
  • Delete .tt files in model

enter image description here

0
source

All Articles