How To separate database access in .Net Core The Next CEO of Stack OverflowHow do I enumerate an enum in C#?Cross-thread operation not valid: Control accessed from a thread other than the thread it was created onDo zombies exist … in .NET?Why not inherit from List<T>?ConnectionString from appsettings.json in Data Tier with Entity Framework CoreHow do I access Configuration in any class in ASP.NET Core?Consume .Net Core library from .Net standard projectShared data and shared methods in .NET Core RazorHow to get the authenticated user from a separate class library in .Net CoreAuthentication between Projects in .net core

Is it professional to write unrelated content in an almost-empty email?

What flight has the highest ratio of time difference to flight time?

Do I need to write [sic] when a number is less than 10 but isn't written out?

Why isn't acceleration always zero whenever velocity is zero, such as the moment a ball bounces off a wall?

Reference request: Grassmannian and Plucker coordinates in type B, C, D

Chain wire methods together in Lightning Web Components

Domestic-to-international connection at Orlando (MCO)

Missile strike detection (but it's not actually a missile)

Find non-case sensitive string in a mixed list of elements?

Is there always a complete, orthogonal set of unitary matrices?

Why the difference in type-inference over the as-pattern in two similar function definitions?

How to install OpenCV on Raspbian Stretch?

Grabbing quick drinks

Are police here, aren't itthey?

Newlines in BSD sed vs gsed

When you upcast Blindness/Deafness, do all targets suffer the same effect?

Math-accent symbol over parentheses enclosing accented symbol (amsmath)

Solving system of ODEs with extra parameter

Prepend last line of stdin to entire stdin

If Nick Fury and Coulson already knew about aliens (Kree and Skrull) why did they wait until Thor's appearance to start making weapons?

Why do remote US companies require working in the US?

Is French Guiana a (hard) EU border?

How many extra stops do monopods offer for tele photographs?

Does soap repel water?



How To separate database access in .Net Core



The Next CEO of Stack OverflowHow do I enumerate an enum in C#?Cross-thread operation not valid: Control accessed from a thread other than the thread it was created onDo zombies exist … in .NET?Why not inherit from List<T>?ConnectionString from appsettings.json in Data Tier with Entity Framework CoreHow do I access Configuration in any class in ASP.NET Core?Consume .Net Core library from .Net standard projectShared data and shared methods in .NET Core RazorHow to get the authenticated user from a separate class library in .Net CoreAuthentication between Projects in .net core










1















In Webforms you could use an ObjectDataSource, use methods defined in your Business Logic Layer that would get data from your Data Layer, usually a data set or EF. Then all the code accessing database would be all in one place and retrieved logically based on methods.



In .Net Core Razor, how do you organize this?










share|improve this question



















  • 2





    Generally speaking, you just throw it all in a class library. Much more than that I can't say as you haven't provided much information about what you're trying to do.

    – Chris Pratt
    Mar 21 at 18:22















1















In Webforms you could use an ObjectDataSource, use methods defined in your Business Logic Layer that would get data from your Data Layer, usually a data set or EF. Then all the code accessing database would be all in one place and retrieved logically based on methods.



In .Net Core Razor, how do you organize this?










share|improve this question



















  • 2





    Generally speaking, you just throw it all in a class library. Much more than that I can't say as you haven't provided much information about what you're trying to do.

    – Chris Pratt
    Mar 21 at 18:22













1












1








1








In Webforms you could use an ObjectDataSource, use methods defined in your Business Logic Layer that would get data from your Data Layer, usually a data set or EF. Then all the code accessing database would be all in one place and retrieved logically based on methods.



In .Net Core Razor, how do you organize this?










share|improve this question
















In Webforms you could use an ObjectDataSource, use methods defined in your Business Logic Layer that would get data from your Data Layer, usually a data set or EF. Then all the code accessing database would be all in one place and retrieved logically based on methods.



In .Net Core Razor, how do you organize this?







c# entity-framework asp.net-core asp.net-core-mvc entity-framework-core






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 22 at 7:53









ArunPratap

2,35621028




2,35621028










asked Mar 21 at 18:05









JackalJackal

186112




186112







  • 2





    Generally speaking, you just throw it all in a class library. Much more than that I can't say as you haven't provided much information about what you're trying to do.

    – Chris Pratt
    Mar 21 at 18:22












  • 2





    Generally speaking, you just throw it all in a class library. Much more than that I can't say as you haven't provided much information about what you're trying to do.

    – Chris Pratt
    Mar 21 at 18:22







2




2





Generally speaking, you just throw it all in a class library. Much more than that I can't say as you haven't provided much information about what you're trying to do.

– Chris Pratt
Mar 21 at 18:22





Generally speaking, you just throw it all in a class library. Much more than that I can't say as you haven't provided much information about what you're trying to do.

– Chris Pratt
Mar 21 at 18:22












1 Answer
1






active

oldest

votes


















1














.NET Core web apps generally follows the Model View Controller (MVC) pattern, but you can use 'Razor Pages' for simpler apps.



If you're using MVC then in your razor views you should just be displaying data in the model for the view. A model is typically a simple Plain Old C# Object (POCO).



The model is created and populated in the controller from any data source or service.



If you're new to MVC from web forms then this guide on .NET Core MVC should be helpful.



If your app is pretty simple then this guide on Razor Pages might be helpful.






share|improve this answer




















  • 1





    I see, i don't know much about MVC yet but i have started using controllers on a razor pages template, basically just mixing stuff around when it's suitable. So I have a controller for my Car model, GetCars Action will just do the db call and populate it. Looks clean and simple

    – Jackal
    Mar 21 at 18:57












Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55286671%2fhow-to-separate-database-access-in-net-core%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














.NET Core web apps generally follows the Model View Controller (MVC) pattern, but you can use 'Razor Pages' for simpler apps.



If you're using MVC then in your razor views you should just be displaying data in the model for the view. A model is typically a simple Plain Old C# Object (POCO).



The model is created and populated in the controller from any data source or service.



If you're new to MVC from web forms then this guide on .NET Core MVC should be helpful.



If your app is pretty simple then this guide on Razor Pages might be helpful.






share|improve this answer




















  • 1





    I see, i don't know much about MVC yet but i have started using controllers on a razor pages template, basically just mixing stuff around when it's suitable. So I have a controller for my Car model, GetCars Action will just do the db call and populate it. Looks clean and simple

    – Jackal
    Mar 21 at 18:57
















1














.NET Core web apps generally follows the Model View Controller (MVC) pattern, but you can use 'Razor Pages' for simpler apps.



If you're using MVC then in your razor views you should just be displaying data in the model for the view. A model is typically a simple Plain Old C# Object (POCO).



The model is created and populated in the controller from any data source or service.



If you're new to MVC from web forms then this guide on .NET Core MVC should be helpful.



If your app is pretty simple then this guide on Razor Pages might be helpful.






share|improve this answer




















  • 1





    I see, i don't know much about MVC yet but i have started using controllers on a razor pages template, basically just mixing stuff around when it's suitable. So I have a controller for my Car model, GetCars Action will just do the db call and populate it. Looks clean and simple

    – Jackal
    Mar 21 at 18:57














1












1








1







.NET Core web apps generally follows the Model View Controller (MVC) pattern, but you can use 'Razor Pages' for simpler apps.



If you're using MVC then in your razor views you should just be displaying data in the model for the view. A model is typically a simple Plain Old C# Object (POCO).



The model is created and populated in the controller from any data source or service.



If you're new to MVC from web forms then this guide on .NET Core MVC should be helpful.



If your app is pretty simple then this guide on Razor Pages might be helpful.






share|improve this answer















.NET Core web apps generally follows the Model View Controller (MVC) pattern, but you can use 'Razor Pages' for simpler apps.



If you're using MVC then in your razor views you should just be displaying data in the model for the view. A model is typically a simple Plain Old C# Object (POCO).



The model is created and populated in the controller from any data source or service.



If you're new to MVC from web forms then this guide on .NET Core MVC should be helpful.



If your app is pretty simple then this guide on Razor Pages might be helpful.







share|improve this answer














share|improve this answer



share|improve this answer








edited Mar 21 at 18:34

























answered Mar 21 at 18:14









Richard GarsideRichard Garside

41.1k86475




41.1k86475







  • 1





    I see, i don't know much about MVC yet but i have started using controllers on a razor pages template, basically just mixing stuff around when it's suitable. So I have a controller for my Car model, GetCars Action will just do the db call and populate it. Looks clean and simple

    – Jackal
    Mar 21 at 18:57













  • 1





    I see, i don't know much about MVC yet but i have started using controllers on a razor pages template, basically just mixing stuff around when it's suitable. So I have a controller for my Car model, GetCars Action will just do the db call and populate it. Looks clean and simple

    – Jackal
    Mar 21 at 18:57








1




1





I see, i don't know much about MVC yet but i have started using controllers on a razor pages template, basically just mixing stuff around when it's suitable. So I have a controller for my Car model, GetCars Action will just do the db call and populate it. Looks clean and simple

– Jackal
Mar 21 at 18:57






I see, i don't know much about MVC yet but i have started using controllers on a razor pages template, basically just mixing stuff around when it's suitable. So I have a controller for my Car model, GetCars Action will just do the db call and populate it. Looks clean and simple

– Jackal
Mar 21 at 18:57




















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid …


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55286671%2fhow-to-separate-database-access-in-net-core%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How to preserve electronics (computers, tablets and phones) for hundreds of years Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) The network's official Twitter account is up and running again. What content…How might modern humans leave a message for 50,000 years?How would an aquatic race develop computers?How do we make computers care for human life?Keeping supplies for 1000 yearsWhat will cell phones become in 100 years?What body armor protects against a laser?Could a society attain 1800s technology if limited to using copper and bronze?Electricity power (magic) and electronicsScavenging metal resources in post-apocalypse after 100 yearsWhy would precursors create devices that can survive and still work after hundreds of years?

155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해

Convert JSON to MapSimplest way to convert a string representing JSON array into Java array List of key value pairsHow to take String JSON values into HashMapConvert a JSON String to a HashMapCreating BSON object from JSON stringJSONObject - How to get a value ?Better Map ConstructorReading JSON from Url javaUpdate columns if input values are not null otherwise ignore and keep the existing values of column in databaseHow to store object represented as Json string into Couchbase Lite?Go JSON into MapHow do I efficiently iterate over each entry in a Java Map?Sort a Map<Key, Value> by valuesHow to round a number to n decimal places in JavaCan comments be used in JSON?How do I read / convert an InputStream into a String in Java?How can I pretty-print JSON in a shell script?What is the correct JSON content type?How can I deserialize JSON to a simple Dictionary<string,string> in ASP.NET?Why does Google prepend while(1); to their JSON responses?Parse JSON in JavaScript?