I am a novice in asp .net Core 3.1 programming. Thank you for your help.
I created three layers for my project, one for the core, one for the database and one for the web.
The models are in the ِDTOs folder. Now my problem is to create database tables. I do not have access to the Category model.
How can I solve this problem? I would be grateful if you could guide me in full detail.
The project error image as well as the dependencies on each layer are present in the image.
Due to the problem of uploading photos on the site, I had to upload them to another site
Images link
https://pasteboard.co/JNeXGKJ.jpg
https://pasteboard.co/JNeXsXs.jpg
Your Category class is in the project Pipeland.Core.
Your project Pipeland.Web references Pipeland.Core but your project Pipeland.DataLayer does not.
At the moment, classes in Pipeland.DataLayer (including PipelandContext) can't access any classes in Pipeland.Core (including Category)
Create a project reference to Pipeland.Core in your Pipeland.DataLayer project.
Then add the line:
using Pipeland.Core.Dtos
to the top of your PipelandContext.cs file.
This assumes that your Category class is in the namespace Pipeland.Core.Dtos, which it might not be, but I expect it is.
Related
I am trying to learn about the MVC structure of Asp.NET core MVC.
Therefore, I am trying to build a small web app similar to the ecommerce system 'simplcommerce' whose code is open source.
My Solution is split into three parts:
1. Modules
2. Infrastructure
3. WebHost
In the Modules part, I have five different Modules (e.g. Contacts, Core) which have their own Controllers, Models, ViewModels and Views.
Now I am trying to add a new Controller into the Contacts Module.
I have already added two Controllers earlier, which was no problem at all.
But after having changed lots of things (like adding and deleting dependencies, adding Models and Views, etc.) I receive the following error-message when trying to add a new Controller:
"There was an error running the selected code generator:
'The specified runtimeconfig.json [C:...\TestApplication\TestAppplication.Module.Contacts\bin\Debug\netcoreapp2.0\TestApplication.Module.Contacts.runtimeconfig.json] does not exist. "
I have checked the folder from the error message and there is no TestApplication.Module.Contacts.runtimeconfig.json.
But I have also checked the same folder in the original SimplCommerce solution, which I have copied parts from, and there is no such file either.
Where is the file from the error message specified?
And what can I do to solve this problem?
Thank you very much in advance!
This file is automatically generated by Visual Studio when you build the project. Interesting thins is that when I removed this file and added new Controller to my test project, this file appeared although I haven't built the solution. The issue looks like your project cannot be compiled.
Make sure that the project does not have any compile-time errors and try to rebuild it before you add the Controller.
I am doing a refactor of my Xamarin project, in which I want to build nuget-packages for my platform specific projects.
And since you can't make your "App.Droid", "App.iOS" and "App.UWP" into nugets I am using class libraries for this.
My problem is when I put my images (ordinary *.png-files) in my UWP-class library it won't work. It is working in both iOS and Android.
So my question is if anyone knows if this is possible, and if so how?
My current setup is as follows:
My UWP-project is named "App.UWP". This is the project i build and the project has the "App.xaml" and "MainPage.xaml".
I then created a "Class library (Universal Windows)" named "Company.Mobile.Core.UWP".
My "App.UWP" is referencing "Company.Mobile.Core.UWP".
I know I have a working connection between the two. My Custom renderers are in the "Company.Mobile.Core.UWP"-project and not in "App.UWP" and is working fine.
Cheers,
Tobias
Using the base Exrin template, I am unable to use custom controls.
As it stands now, the Droid/iOS projects reference the App/Bootstrapper project, so that seems like the correct place to put them, but when creating a new page or BaseView, I am not able to access the custom control's namespace because the View project does not reference the App/Bootstrapper project.
The Tesla sample app does not have this problem in its current implementation since there is no separation of the App/Bootstrapper and the View projects.
(1) Should a reference to the App/Bootstrapper be placed in the View project or (2) should a reference to the View project be placed in the Android/iOS/etc projects? Or is there a better solution than either of these two?
Edit:
(1) does not work because a reference to the App project from the View would create a circular dependency.
(2) should work (I think), but I'm having trouble getting the Application.Droid project to access the Application.View project namespace because when I add using Application.View;, the namespace isn't found in the Application namespace. Visual Studio attempts to fill in other Application namespaces (.Container, .Logic, .Droid, .Proxy) when I type in using Application.
The native project can have a reference to the View. It already does in a way, because it references the App library, which then references the View. Hence you aren't really adding any further dependencies by doing this, just allowing access further up the chain.
If you are having trouble the namespace, I suggest you start out with
global::Application.
That way it starts from the top, if its getting mixed up with project namespaces.
I am trying to create my first Web project and following the demo on the Microsoft Website they show that when a default web form is selected it adds bunch of default folders and files to the project .
I followed it from the start , but "Models" folder is missing in my project solution .
My question is that does "Models" folder contain some classes and files before or if it is missing i can simply create one manually by following the "Add folder" option . Or am i missing a NuGet package ?
Finally, I figured out that if you don't choose the option for signing in to your freshly created web app through individual accounts, that is if you leave it blank , you won't have Models folder in your project, the reason is that when you check the mentioned option, VS will create a class for you called IdentityModels.cs. So, if you want to have folder Models, in the section Change authentification, choose individual accounts.
If you're not using MVC, you may not see the "Models" folder by default in newer VS versions. You should be ok ignoring the models folder and creating classes in root as long as the relevant references are added in your project, for example based on your tutorial, you maybe missing the data entity, data entity design, data entity linq. So for steps you can try creating these classes in root and if the doesn't succeed, try adding these com references. Go to references, Assemblies, Framework, System.Data.Entity, System.Data.Entity.Design and System.Data..LINQ.
Decided to take a dive into recreating a website so that it's an ASP.NET MVC web application. We were originally using the Entity Framework for it, figured to still use it since it works nicely enough. When doing some reading, noticed the there is no such thing as the App_Code/ folder for MVC applications, and that most people were creating a class library for their needs like that. So what I ended up doing was creating my MVC application and a class library, both in the same solution, and the MVC application was referencing the class library. The class library has my EDMX Entity Data Model file in it since some of my classes reference it and I thought that it would be easiest to have it in the library to reference. So here is a picture to what my solution layout is. But when I build and run the website, I get an error on a page that would reference the Entity Data Model. Here is a picture of what the error is.
So I thought, what if I placed the EDMX into my models folder since the error looks like it's complaining about not finding the entities. Here's a picture of my solution now with the move. But now, I'm getting a different error (picture). I'm kind of at a loss as to where to go from here. Is the way I have everything laid out and designed the proper and most efficient way to do it? If not could someone give me some advice?
Thanks, it's really appreciated!
Yes, you should be able to have the edmx in a class library and reference if from your main project. The first error is likely due to an incorrect connection string (check this blog post) but you may also have changed the build action of the edmx file somehow, make sure it is "Entity Deploy".
The second error is probably because you copied the edmx from your class library into the Models folder and it is still referencing the old namespace. To fix that, open the edmx in designer view and click on the background. One of the properties in the property window is Namespace, make sure that's set to the new place you want to keep it.
Edit:
Some things to try:
Clean and rebuild the project
Delete the Temporary ASP.NET Files folder referenced in the error message
Double check your cshtml files for old references to URG_MVC.Models namespace. For example, the line in the error should be IEnumerable<URGLibrary.Proposal>
Right click the edmx file and select Run Custom Tool to regenerate the model files