Open isakatirci opened 5 years ago
Do you have any more information like what version you are using, what settings you used etc. Ideally can you right click on your tt file and select debug. Let me know which line of code is causing the problem and which variable is null.
I use ASP.NET Scaffolding which is a code generation framework for ASP.NET Web applications. Visual Studio includes pre-installed code generators for MVC and Web API projects. I add scaffolding to my project when I want to quickly add code that interacts with data models.
Normally I would do that without getting an error. But now I get an error. I finally found the solution.
Settings.GenerateSeparateFiles = true
it worked. otherwise I get the error
Thank you. I had the problem too, but now It works
I still can't replicate the problem. @luylucas10 @isakatirci Would you be able to be able to help me out by setting Settings.GenerateSeparateFiles = false
and right clicking on the tt file and selecting Debug T4 Template
and let me know which line of code is causing the problem and which variable is null.
The problem is not with the template, but the vs scaffolding tool. The template works perfectly, but when we want to generate controllers and views from the generated code, the scaffolding fails, why? I don't know. To reproduce, create a mvc or web api project (.net framework), add the poco generator and build. Now, try to add a controller with read/write actions with entity framework, select the model, the context and run. All times that I try this, I get error. But when I set Settings.GenerateSeparateFiles = true, as @isakatirci said, the scaffolding works. Sorry for late response.
I'm getting the error when using Scaffolding to Create MVC controller with Entity Framework. I have never encountered this error before.
The error message:
There was an error running the selected code generator 'Object reference not set to an instance of an object.'