I am using Subsonic MVC Template from this project.
Here is a folder named [Code Template] which contains the .tt files for generating views and controllers. But that is giving me error
"MvcTextTemplateHost not found"
I want to generate the create/edit/list pages based on the tables generated by subsonic. How can I do that?
what you want is this:
http://github.com/subsonic/SubSonic-3.0/downloads
1 add subsonic dll to bin folder
2 add reference to that DLL
3 add a connection string to your web.config or app.config
add the connection string name to your ttinclude file
drag files into your models folder
you are then ready to go
http://subsonicproject.com/docs/The_5_Minute_Demo
brilliant up and running in like 10 mins
Related
I have found out that I need to use Areas in asp.net core and the files arent recognized after they have changed the location, is there a file or extension that I should change-use in order for VS Code and the project to recognize the new location of the MVC files?
the original file's path would be like
~\ProjectName\ProjectName\Models
~\ProjectName\ProjectName\Controller
~\ProjectName\ProjectName\Views
when using areas should have a route like
~\ProjectName\ProjectName\Areas\Models
...
now I wonder if there was an easy way to change the file's path using vs code?
i tried editing launch.json but it doesnt recognize ViewModels folder
"sourceFileMap": {
"/Views": "${workspaceFolder}/Area/Views",
"/Controllers" : "${workspaceFolder}/Area/Controllers",
"/Models":"${workspaceFolder}/Area/Models",
"/ViewModels": "${workspaceFolder}/Area/ViewModels",
}```
I am using Visual Studio 2019 with the latest release of the Core framework. I am creating a new Core MVC app against the Core Framework version 3.1. I have a controller and an action method. I want to create a new view. I am 'Empty' Razor View scaffolded item option. However, I get an error message as follows:
Files and Folders Cannot be
Empty Strings
System reserved names, including 'CON, 'AUX', 'PRN', 'COM1', or 'LPT2'
contain only '.'
have any of the following characters / ? : & \ | # %
The error occurs when selecting the option to add the view and before I ever get the dialogue box asking for the view's name.
Any ideas why I am getting this message?
I had the same problem. After some investigation I realized that my project folder path had a '#' in it (option 4 in the list of errors above). I created the project with a new folder path (e.g. in the c:/somepath/repos folder), which solved the error.
I have 3 .edmx files (.msl, .csdl, .ssdl) in my root project directory where the web.config is. Why are these not updating when I do a 'update model from database'?
I have to manually add the new fields to these files...
.msl, .csdl and .ssdl are result of .edmx compilation, if you do not embedd them into assembly check that "EntityDeploy" is selected for "Build Action" in .edmx file properties (in Solution Explorer) and "Copy to Output Directory" is selected for "Metadata Artifact Processing" in model properties (in model designer), update your model and rebuild solution. After that they will be copied to bin\Debug subfolder.
BTW, you could select "Embedd into Output Assembly", update connection string, remove references to these files from solution and do not care about them anymore.
So I've recently started with ASP.NET MVC 4. I'm using the razor engine.
My question is concerning the view files, with suffix cshtml. It seems to me that these are precompiled into *.cs files by razor which in turn are then compiled into MSIL. (A pattern that is familiar from my days as a JSP developer.) One reason why I am making this assumption is that if I enter some invalid c# code into the cshtml file I get a compilation error displayed like this:
Line 34: public class _Page_Views_BaseDataAdmin_Index_cshtml : ...
And line 34 is not indicative of where the error is in the cshtml file, just as the class _Page_Views_BaseDataAdmin_Index_cshtml seems to refer to a regular .net class not the view file.
So my question is: Where do I find the cs file? Specifically, in the example above, "_Page_Views_BaseDataAdmin_Index_cshtml.cs"? Maybe I need to add some config to tell MVC to keep this .cs file on disk, if so, how do I do this?
Thanks!
A quick tip to find the generated files is to add this to your .cshtml file.
This will show you immediately the full path
<div>This file is compiled to #this.GetType().Assembly.CodeBase</div>
You can find the compiled views in your Temporary ASP.NET Files folder.
First find the .compiled file that corresponds to your view (ex: home.cshtml):
home.cshtml.a8d08dba.compiled
This file contains the assembly name: assembly="App_Web_hkc53urb"
Your .cs file will be the assembly name concatenated with a number: App_Web_hkc53urb.1.cs
An easier approach might be to use Windows search for your view name in the temp ASP.NET directory.
I have written a VERY simple MVC application which just displays a single string from a Resource file. It works just fine on my local machine but when I deploy the project to the web server I get the error.
CS0103: The name 'Resources' does not
exist in the current context
You can very easily replicate exactly what I am doing in just 10 steps!
Create a New MVC 2 Web Application.
(File->New->Project->ASP.NET MVC 2 Web Application, say no to the Unit Testing Project)
Add the "App_GlobalResources" folder.(right click the project and select Add->Add ASP.NET Folder->App_GlobalResources)
Add a Resource File to this folder.(right click the folder and select Add->New Item...->Resources File. Name it Strings.resx)
Add a single string to the Resource table.(Name = "HelloWorld", Value = "I localized Hello World!")
Set the File Properties for the Resource File.(Click the file Strings.resx and int the Properties window set Build Action = "Embedded Resource" and the CustomTool = "PublicResXFileCodeGenerator")
Add a new Controller(Right click the Controllers folder and select Add->Controller... Name it HelloWorldController.cs)
Add a the View(With the cursor in the Index method of the HelloWorldController.cs Press CTRL-M-V. Use the default values including View name = "Index")
Modify the View so that it displays our string from the resource file.Replace the content of the MainContent placeholder with
<h2><%: Resources.Strings.HelloWorld %></h2>
Run it locally to test that it works. Which it should.
Publish it to a web server and visit the url "http://localhost/HelloWorld"
This is where I see the error described at the top.
I would imagine that the settings I've put on the ResX file are incorrect and the resource is not published to the server.
Help is greatly appreciated.
Thanks!
Ah ha! Figured it out. In LARGE part to this article:
http://odetocode.com/Blogs/scott/archive/2009/07/16/resource-files-and-asp-net-mvc-projects.aspx
Sounds like the App_GlobalResources folder is NOT cooperative with MVC. So I moved my ResX file to a new folder~/Resources/Strings/Strings.resx
This along with 1 minor change to set the File Property
Custom Tool Namespace = Resources
and Problem Solved!