Can't get zbu.ModelsBuilder to work in Umbraco 7 - umbraco

I am using Umbraco 7, and have just installed the zbu Models Builder Integration package for asp.net using nuget (by running Install-Package Zbu.ModelsBuilder.AspNet -Pre in my NuGet Package Manager console) (which, from what I can see, always installs both zbu.ModelsBuilder and zbu.ModelsBuilder.AspNet dlls).
But I could not have a taste of this thing working yet.
In my Developer section under the new tab "Models Builder", it seems the page that is being displayed there is incomplete (if I look at the file BuildModels.ascx, which seems to be what is supposed to be rendered there - the asp:PlaceHolder whose ID is 'phGenerate' is not rendering/is missing - I do not see however any errors in chrome's console). Seems to me that I need to press this "Generate" (declared within the placeholder) button to trigger the process.
I tried generating the models using the extension for Visual Studio as well, but to no avail again. Right clicking the newly created cs file and choosing "Run Custom Tool" shows the error "The custom tool 'Zbu.ModelsBuilder' failed. One or more errors occurred.".
I found 2 existing threads in Umbraco Forums on issues on Zbu.ModelsBuilder, but they do not help me:
https://our.umbraco.org/projects/developer-tools/hybrid-framework-for-umbraco-v7/anything/59445-Issues-with-zbuModelsBuilder
https://our.umbraco.org/projects/developer-tools/hybrid-framework-for-umbraco-v7/anything/58147-Zbu-ModelsBuilder-API-version-conflict

Related

Visual Studio Code: using directive missing or invalid, except it isn't

I started messing with the new Visual Studio Code today and I am running into a small "problem"...of sorts.
I have added reference to Npgsql in the project.json of a Web API project and run 'dnu restore' which also updated the project.lock.json to include the proper references. However the code editor highlights an error for every reference to an Npgsql object, giving me the "are you missing a using directive or reference" message for each one, including the 'using Npgsql;'
The really odd part is that the same tooltip that tells me it doesn't recognize the type..also tells me exactly what it is and does. Intellisense still works and if I execute 'dnx: web'...the whole thing runs just fine with no errors.
I am assuming its just a bug in the new editor but who knows, maybe I've not configured something correctly? Anybody else see this?
You might see this when having two frameworks configured in project.json. By default you will have dnx451 and dnxcore50. It might be that the dependency is only available for one of the frameworks but not for the other. Check the error message VSCode gives you - it will include in []-brackets the framework for which the error is valid.

Cannot get both Authentication and Entity Framework working in startup.cs

I am using the most up-to-date code examples and snippets I can find, and I understand that things are changing and moving quickly.
When I use the out-of-the-box Visual Studio "vNext ASP.NET Web Application" template, then authentication and database services work just fine.
However, I think that the template is no longer up-to-date and I would like to use the latest assemblies and methodologies.
If I try to use "Microsoft.AspNet.Security.OAuth" as mentioned here:
https://stackoverflow.com/a/26532837/390480
then I cannot get both Authentication and Entity Framework with SQL Server to work.
What happens is that some methods or properties are no longer available.
Is there any example right now with authentication and EF 7 with SQL working?
Optimally I would like to use UseOAuthAuthorizationServer but that no longer seems to be an option so UseCookieAuthentication is fine.
Thank you.
UPDATE 1:
I have tried the two sample applications "Music Store" and "Identiy Sample".
They would not build/run until I ran the file that comes with them named build.cmd.
So I ran this file but forgot that the last time I ran it it corrupted my system and it corrupted my system again.
Now Visual Studio keeps showing a message box saying:
The project system has encountered an error.
An item with the caption "" already exists in the tree
with the same sort order as the item being added.
Also after running build.cmd I now get hundreds of errors such as:
Error 1 The type or namespace name 'AspNet' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
I don't know what fixed it last time. Trying to fix again now.
UPDATE 2:
I remember how I repaired my system now. I recorded the steps here and will try it again now. It's about a 1 hour process.
http://forums.asp.net/p/2013828/5795198.aspx?Re+Can+t+creat+new+project
first get the latest KRE
with Command prompt (run as admin)
#powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/aspnet/Home/dev/kvminstall.ps1'))"
right click on your project and pick newer version KRE !
http://i.stack.imgur.com/dxGth.png
update all your project.json packages to RC1
i.stack.imgur.com/YYAIe.png
and last part on ASP.Net 5 starter Web Template has migration files under Migration folder
and from beta1 to RC there are some changes happened on method names (like GenerateValuesOnAdd is now GenerateValueOnAdd) need to be fixed
and you are ready to go
**** I prefer to start ASP.NET 5 Empty project and select and test everything Step by Step you can also follow that way too ***
(Sorry I want to do a better job on this but stackoverflow doesn't let me put links or images with my reps)

Cannot add a MVC controller VS2012 gives "object reference not set to an instance of an object"

I have searched extensively and cannot find another person on the planet with this problem...
The symptoms are:In Visual Studio 2012, on a MVC 4.0 Project that was upgraded from VS2010 and is configured for dual version editing from VS2012 and VS2010. When I right-click on the Controllers Folder and select Add->Controller... from the context menu, I get an "Object reference not set to an instance of an object" error from Visual Studio.
The existing code in the project runs fine, and if I use the Add->New Item option instead, and pick the Controller from the dialog box, then I can add a blank controller. I just cannot add a typed controller using the method above.
If I however create a new MVC4 Project, then I can add typed controllers again using the same menu, so the problem does not exist in Visual Studio's installation, it has to exist in the Project File. I have also checked the references between my project and a new MVC Project and all the new project references are included in my project.Has anyone experienced something similar?How do I fix this?
The issue seems to have been caused by an incomplete install/registration of the MvcScaffolder package.
The following process resolved my issue for me.
Start Visual Studio and open the project. Open the Package Manager Console. (This was the "trick" or missing piece of information that led to the solution...)
Here I saw the following error caused by the PowerShell script used for registration:
New-Object : Could not load file or assembly 'System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
At <ProjectPath...>\packages\MvcScaffolding.1.0.9\tools\registerWithMvcTooling.ps1:163 char:27
+ $newProvider = New-Object <<<< $powerShellScaffolderProviderType($mvcScaffoldingProvider)
+ CategoryInfo : NotSpecified: (:) [New-Object], FileNotFoundException
+ FullyQualifiedErrorId : System.IO.FileNotFoundException, Microsoft.PowerShell.Commands.NewObjectCommand
When I checked the registered scaffolders from the Package Manager Console I got:
PM> get-defaultscaffolder
DefaultName ScaffolderName
Action MvcScaffolding.Action
Controller MvcScaffolding.Controller
CustomScaffolder T4Scaffolding.CustomScaffolder
CustomTemplate T4Scaffolding.CustomTemplate
DbContext T4Scaffolding.EFDbContext
Mailer Mailer.Razor
Repository T4Scaffolding.EFRepository
UnitTest MvcScaffolding.ActionUnitTest
View MvcScaffolding.RazorView
Views MvcScaffolding.Views
So clearly the scaffolders are configured to use the MvcScaffolding package, but the package had a registration error.
A quick search for the error provided this link http://mvcscaffolding.codeplex.com/discussions/437692 which refers to https://visioautomation.codeplex.com/discussions/397034 that suggests installing PowerShell 3, which is actually part of the Windows Management Framework 3.0, available from http://www.microsoft.com/en-us/download/details.aspx?id=34595. I picked the Windows6.1-KB2506143-x64.msu file when prompted because I’m running Win 7-64-bit.
Restart the PC after installation, re-open Visual Studio and the project and look at the Package Manager Console. If the error is gone, then so is the controller problem.
I had this problem on VS2012 on Win8, We where working on a project that we started developing on VS2010 and i wasn't able to create new controllers with the CTRL+M, CTRL+C shortcut.
Opening any project and re-installing MvcScaffolder and its dependencies under Manage Nuget package have fixed this for me.
Didn't have to restart VS2012 at all.
Maybe your existing project have wrong ProjectTypeGuids element in .csproj file?
Right one for MVC4 is {E3E379DF-F4C6-4180-9B81-6769533ABE47}.
Try to compare what project type do you have in new project and in your existing project.
The preferred answer of installing the Windows Management Framework 3.0 did not work. The download "Windows6.1-KB2506143-x86.msu" did not work on my Windows 7 32 bit system. It failed with the error "The update is not applicable to your computer".
Reinstalling MVCscaffolding with Manage Nuget Packages did not work.
My ProjectType GUID was correct.
Microsoft Web Developer Tools was already installed.
Deleting and recreating the solution didn't work.
It was necessary to repair the Visual Studio 2012 installation from the install disk to fix this issue.
Installing "Microsoft Web Developer Tools" fixed this for me. Related:
How do I open a csproj with ProjectTypeGuids 349c5851-65df-11da-9384-00065b846f21?
{E3E379DF-F4C6-4180-9B81-6769533ABE47} - MVC4 Project
{fae04ec0-301f-11d3-bf4b-00c04f79efbc} - CSharp Project
{349c5851-65df-11da-9384-00065b846f21} - Web Application Project (this is what you need web dev tools for)
The update Windows6.1-KB2506143-x64.msu worked for me. The problem started after a full SpyWare software scan. I think that it removes more things than the usual. So, back to normal life.
I had the same problem, im using database first, and it was because i have changed the .edmx contex.tt to generate the contex.cs with the connection name set to a custom method,
: base(sqlHelper.getMainConnectionString())
every time, before i change/update the .edmx, i need to change the connection name to it's creation defaults:
: base("name=YourWebconfigConnectionstringName")
rebuild the project and it works again
Answer:
Check your connectionstring string and provider parameters at the webconfig, then delete and recreate the .edmx this will force the generator to rebuild all the database objects, metadata included OR delete all tables in the designer, change the contex.cs to the default creation name, rebuild the project, add the tables, rebuild the project, it shoul work again.
This problem manifested on a target MVC5 project using VS2017.
Like the original op, a new project was attempted to perform an Add Controller with EF scaffolding against ApplicationUser. The error did initially manifest until a single user was registered forcing the database to be created. After that, add scaffolding worked without incident. I think this makes sense because the entity didn't really yet exist before the first registration, although I will stand corrected if someone more knowledgeable than myself has a more accurate explanation. But because Add Controller worked with a new project, just as the original op determined, it didn't seem to be a VS2017 installation problem. This pointed to something wrong with the taret project.
At this point in the target project an Undo All in Team Explorer was executed to get the project back to a previously working point. While this might be accomplished by getting a specific version, for this target project all that was required was an Undo All. A word of caution: in the case of this specific project, before undoing, the Package Manager was used to rollback the database to the starting point that would match with the Undo All. If one performs a get specific version, be sure to check if the database needs to get rolled back to the proper configuration. After resetting all the project changes, the object reference not set to an instance of an object error was no longer present during the Add Controller operation, fixing the error within the target project.
I post this response somewhat reluctantly because I am unable to duplicate the error, and I am unsure of what actually caused the problem in the first place, but this is a particularly nasty error if one is in the middle of a project and Add Controller starts failing. I figured if someone has this problem and rolling back the current change set might fix it for them, like me they will be thankful. If I later determine the pattern of activity that caused the problem to crop up in the first place, I'll surely add more to this post.
I'm running VS 2019 Enterprise, ASP.NET Core 3.1.3.
I was trying to add MVC controller with views using Entity Framework (EF) after scaffolding in database first approach.
I run on this issue because one of the tables in my ER model was missing primary key.
That table was connected to table for which I tried to generate MVC controller through another table that has primary key so I didn't noticed initially that error.

MVC View designer complains "There is no endpoint listening at net.pipe://localhost/

I recently installed Visual Studio 2012 (Ultimate edition) Update 2. I'm not sure if this problem is related to that update but.. now, when I view any of my View (.aspx) code in the VS designer, the initial #model or #using directive gets a squiggly underline and an associated error message of "There is no endpoint listening at net.pipe://localhost/xxx". All of the code in the page that relies on the #model or #using directive gets its own associated squiggly underline errors. But the code runs just fine. The error is in the designer, not in the runtime JIT compiler magic.
Any suggestions?
After a bit more digging, I found a blog post that suggested that the problem might be caused by failing to run VS as administrator. I tried that (I ran VS as administrator and loaded the offending solution) and, bada bing, bada boom, problem solved.
I've been happily skipping the "run as administrator" rigmarole for ASP.NET projects, and everything has worked correctly. I guess they must have changed something in Update 2 that now requires ASP.NET MVC projects to be opened with admin privs.
Can someone who knows better than I confirm this diagnosis?
(BTW, I ran across this post that shows how to force VS to always run with admin privs on Windows 8. This is an all-or-nothing solution... What I'd REALLY like is for the VS developers - or someone with time on their hands - to add a context menu item to .sln files to open them in VS with admin privs enabled.)
EDIT:
4 months after I posted this "solution" (actually, a work-around), here's where I am: I opened an incident with MSDN tech support. After much work, we got nowhere; still no clue what the underlying problem might be. But this problem only exists on my desktop PC - my laptop doesn't have the problem - and I'm buying a new PC, so the problem should go away when I install VS on the new PC and turn the old PC into a doorstop.

Add View Model class dropdown not showing my class

I’ve created a new C# asp.net mvc 4.0 (beta) Internet Application and I’m having a somewhat odd behavior in the Add View dialog in Visual Studio 2010 (sp1).
When I decide to create a strongly-typed View, inside the Add View dialog, the Model class dropdown does not show my ViewModel class.
For the record, yes I did compile the application before triggering the Add View dialog.
I believe I have pinpointed the issue but do not know how to fix it.
Below are the repro-steps if anyone cares to reproduce the behavior:
In Visual Studio 2010 (sp1), create a new C# asp.net MVC 4.0
(beta) Internet Application.
Inside the Models folder, create a new simple class called
“GazouViewModel.cs”
Build the application, open the HomeController, right-click the
Index() ActionResult and select Add View…
In the Add View dialog, check the “strongly-typed view” checkbox and
in the Model class: dropdown, you’ll notice your “GazouViewModel”
In Solution Explorer, right-click your project and select “Manage
NuGet Packages”
Search, find and install the “Bootstrapper.Autofac” package.
Rebuild the application and verify if your “GazouViewModel” still
displays inside the Add View dropdown’s dialog.
The “GazouViewModel” should still be displaying in the dropdown.
In Solution Explorer, right-click your project and select “Manage
NuGet Packages”
Search, find and install the “Autofac ASP.NET MVC4 (Beta)
Integration” package.
Rebuild the application and verify if your “GazouViewModel” still
displays inside the Add View dropdown’s dialog.
The “GazouViewModel” should still be displaying in the dropdown.
In Solution Explorer, right-click your project and ADD a new class
(Class1.cs) anywhere it doesn’t matter.
Make that Class1 implement IAutofacRegistration and implement the
interface.
Rebuild the application and verify if your “GazouViewModel” still
displays inside the Add View dropdown’s dialog.
The “GazouViewModel” is no longer showing inside the Model class
dropdown.
It appears that as soon as I create a class that implements the IAutofacRegistration interface and build the application, I’m no longer capable of viewing my ViewModels in that dropdown.
Can anyone confirm if they are getting the same results as me?
And more importantly, how can one fix this?
IMPORTANT: I have tried the exact same steps with an mvc 3.0 application and the exact same behavior occurs…so this is not relevant to the BETA version.
Sincerely
Vince
If you get error message: "Running transformation: The input file appears to be using a schema version not supported by this template. This may lead to compile errors. Please use 'Add New Generated Item' to add an updated template".
You are used EF 5.x. You have to add metadata for EF 5.x to your T4 template. In file header call DefineMetadata()
<## template language="C#" debug="false" hostspecific="true"#>
<## import namespace="System.Text.RegularExpressions" #>
<## include file="EF.Utility.CS.ttinclude"#><## output extension=".cs"#><#
DefineMetadata();
at the bottom of your template create method
private void DefineMetadata()
{
TemplateMetadata[MetadataConstants.TT_TEMPLATE_NAME] = "CSharpDbContext.Types";
TemplateMetadata[MetadataConstants.TT_TEMPLATE_VERSION] = "5.0";
TemplateMetadata[MetadataConstants.TT_MINIMUM_ENTITY_FRAMEWORK_VERSION] = "5.0";
}
I solved this issue by beeing mad in like 2 hours and then deleting the Assembly.cs from the Properties-folder in the solution. After I made a rebuild of the solution, the "Add-view" model-dropdown suddently could find all my ViewModels, strange enough.
I guess the assembly version defined in Assembly.cs somehow got mixed up with the actual version used in the project. Anyhow, it works now for my case.
What worked for me was to simply build the solution after creating my model. Then I was able to find my model in the dropdownlist.
I've noticed this issue as well (using MVC 4 Beta on Visual Studio 2010). Re-starting Visual Studio solved the problem for me.
Just another solution to add to the pile as none of the other ones worked for me. This is another example of Visual Studio being terrible at handling long file paths and namespaces.
In my case the namespace was too long to display in the "Model class" dropdown. Shortening the namespace (a ridiculous pain in of itself) made the drop down work again!
UPDATE: As of this writing, I can no longer reproduce the error. Perhaps the NuGet packages I use have been updated to a newer version and incidentally fixed the error.
I will mark this post as closed.
Thanks for everyone’s input on this!
Vince
Just Clean and build your solution. It worked for me.
Using VS 2010 and MVC 3.0, at one point the Add View Model class dropdown was not showing any classes for me. Ivan's suggestion of restarting VS appeared to work for me.
I tried deleting AssemblyInfo.cs, did a Clean, and a Rebuild, but those didn't resolve the issue. When I restarted VS, the model classes were back in the dropdown.
I realize this is a bit out of date. I had a similar situation where my classes wouldn't load into the View Template wizard. I'm using VS 2012 with MVC3. Everyone else in the team was OK, just luckily old me had issues. After much research and trying lots of things the only thing that has consistently fixed it is running VS in safemode (from the command prompt: "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\devenv.exe" /safemode). One of my extensions must be causing the issue and by running in Safe Mode those aren't loaded.

Resources