1

I have an ASP.NET MVC application which is using Entity Framework.

One of the projects in the visual studio solution uses Entity Framework and contains an edmx file under Model folder. Within this folder there are some model files that are automatically generated as a result of the entity model.

I have noticed that in this model folder are missing some model files, I mean, there are not included in the model folder. In the model folder there are some model files but not all of them. The missing model files exist in the physical path so I try to add them to the project under model folder but afert thgat they continue not appearing there.

How can I successfully add the missing model files to the project folder "Model"?

I am using Visual Studio 2013 and .NET 4.5.

Willy
  • 9,848
  • 22
  • 141
  • 284
  • What are file extension of the _model files_ you referred to? – Jackdaw Nov 17 '20 at 11:11
  • @Jackdaw The extensions of the model files are .cs (,Net CSharp). I am trying to include them under the Model folder because they are missing (they do not appear there as other model files do). – Willy Nov 17 '20 at 17:06
  • If `*.cs` files under _Model.edmx_ are removed this should not be a problem. They automatically will be generated by the *EntityModelCodeGenerator*. Just make some change if the model diagram and the Visual Studio will recreate the *.cs file under the _Model.edmx_. – Jackdaw Nov 17 '20 at 17:53
  • 1
    You wrote: _The missing model files exist in the physical path so I try to add them to the project under model folder but after that they continue not appearing there._ It is because of they are not included directly to the project. You can see this if will open the project file in a text editor. The _*.cs_ files included to the project with the `DependentUpon` option. Like `Model1.tt`. – Jackdaw Nov 17 '20 at 18:14
  • @Jackdaw Yes, you are right. The missing model files that are not shown under Model folder in the Visual Studio project appear in the project file as Model1.tt. I was trying to add (check-in) those missing files to team foundation server so for this reason I was trying to make them visible under Model folder in order to check-in them later and upload them to TFS. So how can I check-in them if they are not shown under Model folder in the project? – Willy Nov 17 '20 at 19:09
  • 1
    Of course, to check-in the files it is necessary to make them visible. The shortest way to make the files visible just recreate them automatically by the following steps: **1)** In the Visual Studio click on the Entity Data Model Designer file (_Model1.edmx_). **2)** Select any Entity Set (usually table projection). **3)** Move the selected Entity Set to any direction, to make changes in the Entity Data Model Designer file. **4)** Press Ctrl+S (Save). The Visual Studio will call _EntityModelCodeGenerator_ to recreate the _*.cs_ file under _Model1.tt_. – Jackdaw Nov 18 '20 at 10:41

0 Answers0