CleanArchitecture | repository contains the implementation | Architecture library
kandi X-RAY | CleanArchitecture Summary
kandi X-RAY | CleanArchitecture Summary
This repository contain the implementation of domain driven design and clear architecture in ASP.NET Core.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of CleanArchitecture
CleanArchitecture Key Features
CleanArchitecture Examples and Code Snippets
Community Discussions
Trending Discussions on CleanArchitecture
QUESTION
I using CleanArchitecture solution. I have Data layer where ApplicationDbContext and UnitOfWork are located :
...ANSWER
Answered 2021-Jun-13 at 12:31finally, I found my answers in this article https://snede.net/you-dont-need-a-idesigntimedbcontextfactory/
Create ApplicationDbContextFactory in Portal.Data project:
QUESTION
I am having trouble wiring up identity into Blazor server with ASP.NET Core identity. Specifically getting the correct logged in state in Blazor pages (while I am getting them from the Blazor pages).
I think it's related to some of the startup being initialized in another project - but not sure how to debug it or what the solution is to be able to get the logged in state correctly.
Reproduction steps and link to GH repo below as a POC.
Background
I'm porting over the clean-code project by JasonTaylor from Angular / ASP.NET Core to a Blazor server project with ASP.NET Core Identity.
Issue
The application runs up and I can browse the pages when I register I can see logged-in state in the identity-based default pages but in the Blazor pages that use the AuthorizeView
(e.g. LoginDisplay.razor
) it's not aware of being authorized.
Startup in the Blazor project:
...ANSWER
Answered 2021-Jun-10 at 08:10This was an issue with mixing IdentityServer and ASP.net identity.
By removing Microsoft.AspNetCore.ApiAuthorization.IdentityServer
and the use of base class from ApiAuthorizationDbContext
back to IdentityDbContext
resolved this.
QUESTION
What is the best way to call a SQL function / stored procedure when converting code to use the repository pattern? Specifically, I am interested in read/query capabilities.
Options
- Add an
ExecuteSqlQuery
toIRepository
- Add a new repository interface specific to the context (i.e.
ILocationRepository
) and add resource specific methods - Add a special "repository" for all the random stored procedures until they are all converted
- Don't. Just convert the stored procedures to code and place the logic in the service layer
Option #4 does seem to be the best long term solution, but it's also going to take a lot more time and I was hoping to push this until a future phase.
Which option (above or otherwise) would be "best"?
NOTE: my architecture is based on ardalis/CleanArchitecture using ardalis/Specification, though I'm open to all suggestions.
...ANSWER
Answered 2021-May-02 at 16:21Don't treat STORED PROCEDURES as 2nd order citizens. In general, avoid using them because they very often take away your domain code and hide it inside database, but sometimes due to performance reasons, they are your only choice. In this case, you should use option 2 and treat them same as some simple database fetch.
Option 1 is really bad because you will soon have tons of SQL in places you don't want (Application Service) and it will prevent portability to another storage media.
Option 3 is unnecessary, stored procedures are no worse than simple Entity Framework Core database access requests.
Option 4 is the reason why you cannot always avoid stored procedures. Sometimes trying to query stuff in application service/repositories will create very big performance issues. That's when, and only when, you should step in with stored procedures.
QUESTION
I'm getting this error:
Database operation expected to affect 1 row(s) but actually affected 0 row(s)
when adding a new element to the entity's collection.
Base classes in Domain
project:
ANSWER
Answered 2021-Apr-19 at 16:36The problem was that by generating my Id's manually, the new entity got the Modified
state, instead of Added
state. The fix was using the Fluent API's .ValueGeneratedNever()
method with the modelBuilder
.
QUESTION
I was trying to publish a solution using Visual Studio but I'm really stucked at this point. I got my little project using Clean arhitecture solution template but when trying to publish it nothing seems to work.
What I've tried:
- publishing each project one by one, but the frontend (angular) won't communicate with the backend(.net core)
- updating node and python
- reinstalling python and node
- running the visual studio by administrator
- trying to publish the template from github, without my very own code in it
- update the csproj file from
npm run build -- --prod
tonpm run build --prod
I also tried to look for this error on the internet, I already tried every solution but nothing seems to work for me.
You can find here a picture of the console: Link to the image
...ANSWER
Answered 2021-Apr-12 at 08:45Your problem is caused by the local computer environment. I solved it locally, but I don't have a clear solution for you. I can only provide you with ideas, because every environmental computer in our development is different.
Installed on my pc
1. python 3.8
2. npm
3. node 14
The best way to solve this problem is to perform a Google search according to the error prompt, so that the problem can be solved step by step. (It took me 2 hours to successfully release the program, but there are still problems with the program after the release, which may be caused by some specific factors)
According to your error message,
First install python2.7,
Upgrade npm to the latest version,
Execute
npm install -g node-sass
.
Follow the error prompt and perform a Google search for subsequent errors.
Local test results:QUESTION
I'm using Jason Taylor's Clean Architecture template and I wonder why his WebUI Dockerfile is generated by Visual Studio just like below.
It sets WORKDIR
to /src
and then copies each project from /src/ProjectDir/Project.csproj
. What's the point of WORKDIR in that case? Look at WORKDIR "/src/src/WebUI"
. Why /src/src
? There is only one src directory.
ANSWER
Answered 2021-Mar-27 at 17:56I suspect this is because WORKDIR /src
will create a directory called /src AND change directories into it. After changing into it, it will copy files from the host's relative src folder and into another subdirectory called src (on the container). So the full absolute path becomes /src/src. You can confirm this by adding RUN pwd && ls
before the WORKDIR
and after the first COPY
.
QUESTION
I want to add items to test database for integration test . These tables have many-to-many relation (I config them in database context) I want to add new record to watchlist table but AddAsync throws DbUpdate Exception
Violation of PRIMARY KEY constraint 'PK_Movies'. Cannot insert duplicate key in object 'dbo.Movies'. The duplicate key value is (f48bd131-79ad-47bc-8cf2-1ece8ba648c2). The statement has been terminated.
EF thinks I want to update movie entity but I want to add item to Watchlist and link table (MovieWatchlist)
my project is base on CleanArchitecture
...ANSWER
Answered 2021-Feb-03 at 10:43I believe your problem is that EF Core's change tracker is not tracking the given entities, because when you call AddAsync()
it creates a new scope and a new DbContext
.
I started to use the same integration testing method recently, and it's great, but the testing helper methods won't get you far without extending them quite a bit. A better way of handling DbContext
would probably be to instantiate one per test case, instead of one per each operation.
Anyhow, one easy solution is to attach the given entities to the current DbContext
in the same scope you're inserting the new Watchlist
. A crude modification to your attach method implementing this change:
QUESTION
I have a .net Core 3.1 app running in an azure web app for containers(linux) service. This app is a web api project with an angular 9 front end. It uses Identity server 4 for authorization.
For reference I am using this clean architecture framework template for my project (the add docker support pr).
The app runs in the service just fine. The front end works and I can "log in" using ID4 and I can see that the authorization token are returned when I log in.
THE PROBLEM:When I make a call to the backend web api from the front end angular client app I get the following error:
...ANSWER
Answered 2020-Nov-13 at 10:48You need to capture your token and use https://jwt.ms to parse it.
According to your error message: invalid token The issuer is invalid
, so you should check the iss
Claims in the token to make sure it is as expected in the API The issuer matches. see here.
QUESTION
I am trying to use the .Net Core Clean Architecture App Template and get it running in containers and deployed through an azure CI/CD pipeline
I have the containerized version of the template running locally in linux container with port 5001 and everything works perfectly.
I have the azure pipeline build process working properly and it creats image in my container registry.
The problem is once I deploy/release to a Web App for Containers, the app fails and throws the following error:
Application startup exception System.InvalidOperationException: Couldn't find a valid certificate with subject 'CN=localhost' on the 'CurrentUser\My' at Microsoft.AspNetCore.ApiAuthorization.IdentityServer.SigningKeysLoader.LoadFromStoreCert(String subject, String storeName, StoreLocation storeLocation, DateTimeOffset currentTime)
What I have done:
Following these docs from MS I have created a local dev cert:
dotnet dev-certs https -ep %USERPROFILE%\.aspnet\https\aspnetapp.pfx -p { password here }
dotnet dev-certs https --trust
I then imported this into the Web App as a private .pfx cert.
I added an application setting WEBSITE_LOAD_CERTIFICATES with the "thumb" value of the cert
I used the "hostname" of the imported cert in the Identity Server appSettings.json section (hostname=localhost in my case)
When the Web app loads, it shows :( Application error and the docker logs give me the error I quoted above.
I am pretty sure this is related to the Identity server set up and the appSettings.json values here:
...ANSWER
Answered 2020-Sep-07 at 14:10I think the problem is that your application in the container does not trust the locally created developer certificate. Its something you can only use on your machine because a dev root certificate is installed on your computer.
The container will never trust the certificate created by dotnet dev-certs.
You need to get a properly trusted certificate, for example from LetsEncrypt.
QUESTION
I have a .net core 3 app running locally/development just fine, both on its own and when run in a linux container. I then take the app and have it built into a docker image inside azure pipelines. The image is loaded to azure container registry.
Finally, I have an Azure Web APP for Containers (Linux) that uses the image to run.
Locally I have the docker-compose file set up like this:
...ANSWER
Answered 2020-Nov-04 at 09:03Is it possible that your docker-compose
file has an error in the definition of the service volumes
?
You have the following docker-compose
fragment for your service:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install CleanArchitecture
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page