Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Namespace error when using T4MVC

Just heard about T4MVC but i can't get it to work in my sample project (ASP.NET MVC 2, Visual Studio 2008).

I get the following erros when trying to build the project:

Error 1 The type or namespace name 'Account' does not exist in the namespace 'Northwind.Web.MVC' (are you missing an assembly reference?) C:\Users\Bruno\Documents\My Dropbox\Projetos.NET\Northwind\Northwind.Web.MVC\AccountController.generated.cs 38 61 Northwind.Web.MVC

This is where the error occurs:

[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public AccountController Actions { get { return MVC.Account; } }

I really hate magic strings, so please help me to make it work!

like image 608
brunosp86 Avatar asked Feb 26 '23 02:02

brunosp86


1 Answers

Looks like a namespace conflict between T4MVC and your code. Go to T4MVC.settings.t4 and find this code:

// The prefix used for things like MVC.Dinners.Name and MVC.Dinners.Delete(Model.DinnerID)
const string HelpersPrefix = "MVC";

Just change "MVC" to something else and you'll be on your way :)

Alternatively, you could rename your namespace if you prefer (Northwind.Web.MVC)

like image 115
David Ebbo Avatar answered Apr 29 '23 04:04

David Ebbo