<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>EntityFramework Archives - scmGalaxy</title>
	<atom:link href="https://www.scmgalaxy.com/tutorials/tag/entityframework/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.scmgalaxy.com/tutorials/tag/entityframework/</link>
	<description>A Platform for Software Engineers</description>
	<lastBuildDate>Sat, 21 Feb 2026 07:14:02 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1</generator>
	<item>
		<title>Mastering LINQ to SQL: Use Cases, Architecture, Workflow, and Getting Started Guide</title>
		<link>https://www.scmgalaxy.com/tutorials/mastering-linq-to-sql-use-cases-architecture-workflow-and-getting-started-guide/</link>
					<comments>https://www.scmgalaxy.com/tutorials/mastering-linq-to-sql-use-cases-architecture-workflow-and-getting-started-guide/#respond</comments>
		
		<dc:creator><![CDATA[Vijay K]]></dc:creator>
		<pubDate>Thu, 03 Jul 2025 12:03:00 +0000</pubDate>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[CSharp]]></category>
		<category><![CDATA[DataAccess]]></category>
		<category><![CDATA[DatabaseProgramming]]></category>
		<category><![CDATA[DOTNET]]></category>
		<category><![CDATA[EntityFramework]]></category>
		<category><![CDATA[LINQtoSQL]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[SoftwareDevelopment]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[TechEducation]]></category>
		<guid isPermaLink="false">https://www.scmgalaxy.com/tutorials/?p=13107</guid>

					<description><![CDATA[<p>What is LINQ to SQL? LINQ to SQL is a component of the Language Integrated Query (LINQ) framework in the [&#8230;]</p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/mastering-linq-to-sql-use-cases-architecture-workflow-and-getting-started-guide/">Mastering LINQ to SQL: Use Cases, Architecture, Workflow, and Getting Started Guide</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-image size-full"><img fetchpriority="high" decoding="async" width="930" height="430" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2025/07/image-37.png" alt="" class="wp-image-13121" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2025/07/image-37.png 930w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2025/07/image-37-300x139.png 300w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2025/07/image-37-768x355.png 768w" sizes="(max-width: 930px) 100vw, 930px" /></figure>



<hr class="wp-block-separator has-alpha-channel-opacity">



<h3 class="wp-block-heading"><strong>What is LINQ to SQL?</strong></h3>



<p class="wp-block-paragraph"><strong>LINQ to SQL</strong> is a component of the <strong>Language Integrated Query (LINQ)</strong> framework in the <strong>.NET</strong> ecosystem, specifically designed to interact with <strong>SQL Server</strong> databases. LINQ to SQL provides a straightforward and efficient way to query relational data in SQL Server using <strong>C#</strong> or other .NET languages. It allows developers to write SQL queries directly in the programming language, making it easier to interact with databases without writing raw SQL statements.</p>



<p class="wp-block-paragraph">Unlike traditional <strong>ADO.NET</strong> that requires developers to manually manage database connections, commands, and data mapping, <strong>LINQ to SQL</strong> automates much of the interaction between the application and the database, simplifying data retrieval and manipulation.</p>



<p class="wp-block-paragraph"><strong>LINQ to SQL</strong> translates LINQ queries into <strong>SQL queries</strong> that are executed on the server, allowing for more compact, readable, and efficient data operations.</p>



<hr class="wp-block-separator has-alpha-channel-opacity">



<h3 class="wp-block-heading"><strong>Key Features of LINQ to SQL:</strong></h3>



<ol class="wp-block-list">
<li><strong>Object-Relational Mapping (ORM)</strong>: LINQ to SQL provides ORM capabilities, meaning it automatically maps <strong>database tables</strong> to <strong>C# objects</strong>, allowing developers to work with data in an object-oriented way.</li>



<li><strong>SQL Query Generation</strong>: LINQ to SQL automatically generates <strong>SQL queries</strong> based on LINQ expressions, reducing the need to manually write raw SQL.</li>



<li><strong>Strongly Typed</strong>: LINQ to SQL provides a strongly-typed <strong>DataContext</strong>, which ensures compile-time validation of queries and data manipulations.</li>



<li><strong>Change Tracking</strong>: LINQ to SQL tracks changes made to objects and automatically generates the corresponding <strong>SQL UPDATE, INSERT, or DELETE</strong> statements when changes are saved to the database.</li>



<li><strong>Lazy Loading</strong>: Supports <strong>lazy loading</strong>, which means related data can be loaded on-demand when accessed, improving performance by only querying necessary data.</li>
</ol>



<hr class="wp-block-separator has-alpha-channel-opacity">



<h3 class="wp-block-heading"><strong>What Are the Major Use Cases of LINQ to SQL?</strong></h3>



<p class="wp-block-paragraph">LINQ to SQL is typically used in scenarios where developers need to interact with relational databases, particularly <strong>SQL Server</strong>, within .NET applications. Below are some <strong>major use cases</strong> of <strong>LINQ to SQL</strong>:</p>



<h4 class="wp-block-heading"><strong>1. Data-Driven Web Applications:</strong></h4>



<ul class="wp-block-list">
<li><strong>Use Case</strong>: LINQ to SQL is often used in <strong>web applications</strong> to retrieve, manipulate, and display data stored in SQL Server databases.</li>



<li><strong>Example</strong>: A <strong>customer management system</strong> that allows users to view, add, update, and delete customer information from a SQL Server database.</li>



<li><strong>Why LINQ to SQL?</strong> LINQ to SQL simplifies database queries and automatically handles data mapping, making it ideal for applications that need to interact with relational data.</li>
</ul>



<h4 class="wp-block-heading"><strong>2. Enterprise Applications with Complex Data Models:</strong></h4>



<ul class="wp-block-list">
<li><strong>Use Case</strong>: In <strong>enterprise applications</strong>, LINQ to SQL is used to manage <strong>complex data models</strong>, providing a clean, object-oriented approach to interact with databases.</li>



<li><strong>Example</strong>: An <strong>inventory management system</strong> that tracks product data, stock levels, and transactions, all stored in a SQL Server database.</li>



<li><strong>Why LINQ to SQL?</strong> The object-relational mapping (ORM) capabilities make it easier to work with relational data without worrying about manual data transformation.</li>
</ul>



<h4 class="wp-block-heading"><strong>3. Data Analysis and Reporting Tools:</strong></h4>



<ul class="wp-block-list">
<li><strong>Use Case</strong>: LINQ to SQL is ideal for <strong>data analysis</strong> tools where users need to query large datasets from SQL Server and perform operations like filtering, grouping, and aggregation.</li>



<li><strong>Example</strong>: A <strong>financial reporting application</strong> that retrieves data from a SQL Server database and displays reports based on user-selected filters (e.g., date ranges, transaction types).</li>



<li><strong>Why LINQ to SQL?</strong> Its ability to generate complex SQL queries through LINQ syntax simplifies data analysis operations and makes code more maintainable.</li>
</ul>



<h4 class="wp-block-heading"><strong>4. Simplified Database Interaction for CRUD Operations:</strong></h4>



<ul class="wp-block-list">
<li><strong>Use Case</strong>: LINQ to SQL is used for simplifying <strong>CRUD (Create, Read, Update, Delete)</strong> operations on relational data.</li>



<li><strong>Example</strong>: A <strong>blogging platform</strong> where users can create, read, update, and delete blog posts, all of which are stored in a SQL Server database.</li>



<li><strong>Why LINQ to SQL?</strong> The automatic translation of LINQ queries into SQL and the built-in change tracking system makes CRUD operations faster and less error-prone.</li>
</ul>



<h4 class="wp-block-heading"><strong>5. Legacy Application Integration:</strong></h4>



<ul class="wp-block-list">
<li><strong>Use Case</strong>: LINQ to SQL is used to integrate <strong>legacy applications</strong> that already use SQL Server as their data storage backend, enabling seamless interaction between old systems and modern .NET applications.</li>



<li><strong>Example</strong>: A <strong>legacy CRM system</strong> that uses SQL Server as a backend can integrate LINQ to SQL to provide modern querying capabilities through C# code.</li>



<li><strong>Why LINQ to SQL?</strong> LINQ to SQL reduces the effort required to update legacy systems and provides an intuitive way to query data without refactoring entire codebases.</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity">



<h3 class="wp-block-heading"><strong>How LINQ to SQL Works Along with Architecture?</strong></h3>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="683" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2025/07/image-39-1024x683.png" alt="" class="wp-image-13123" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2025/07/image-39-1024x683.png 1024w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2025/07/image-39-300x200.png 300w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2025/07/image-39-768x512.png 768w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2025/07/image-39.png 1536w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p class="wp-block-paragraph">The <strong>architecture</strong> of <strong>LINQ to SQL</strong> involves the use of several components that work together to enable seamless data access, manipulation, and storage. Below is an overview of how <strong>LINQ to SQL</strong> works:</p>



<h4 class="wp-block-heading"><strong>1. DataContext:</strong></h4>



<ul class="wp-block-list">
<li><strong>Role</strong>: The <strong>DataContext</strong> is the central component of LINQ to SQL. It acts as a <strong>bridge</strong> between your application and the SQL Server database, allowing for data querying and manipulation.</li>



<li><strong>How It Works</strong>: When you query the database using LINQ, the DataContext translates those LINQ queries into SQL queries that are executed on the SQL Server. It also tracks changes made to the objects retrieved from the database, and when you call <strong>SubmitChanges()</strong>, the DataContext generates SQL commands (INSERT, UPDATE, DELETE) to save the changes back to the database.</li>
</ul>



<h4 class="wp-block-heading"><strong>2. Object-Relational Mapping (ORM):</strong></h4>



<ul class="wp-block-list">
<li><strong>Role</strong>: <strong>ORM</strong> in LINQ to SQL maps database tables to <strong>C# classes</strong> and columns to <strong>class properties</strong>. This allows developers to work with objects instead of dealing directly with raw SQL.</li>



<li><strong>How It Works</strong>: Each table in the database corresponds to a class in your application, and each row in the table is represented as an instance of that class. When you query the database, LINQ to SQL creates instances of these classes populated with the data retrieved from the database.</li>
</ul>



<h4 class="wp-block-heading"><strong>3. Entity Classes:</strong></h4>



<ul class="wp-block-list">
<li><strong>Role</strong>: <strong>Entity classes</strong> represent the data structures for the SQL Server tables.</li>



<li><strong>How It Works</strong>: The entity classes are defined in the code and correspond to database tables. These classes are populated with data retrieved from the database via the DataContext.</li>
</ul>



<h4 class="wp-block-heading"><strong>4. LINQ Queries:</strong></h4>



<ul class="wp-block-list">
<li><strong>Role</strong>: <strong>LINQ queries</strong> are used to interact with the database through the DataContext. These queries are written in C# and are automatically converted into SQL queries by LINQ to SQL.</li>



<li><strong>How It Works</strong>: LINQ queries in C# are executed on the DataContext, which sends the queries to the SQL Server and retrieves the results.</li>
</ul>



<h4 class="wp-block-heading"><strong>5. Change Tracking:</strong></h4>



<ul class="wp-block-list">
<li><strong>Role</strong>: LINQ to SQL automatically tracks changes made to objects retrieved from the database, such as modifications, additions, or deletions.</li>



<li><strong>How It Works</strong>: When you modify an object, LINQ to SQL tracks the changes. When you call <strong>SubmitChanges()</strong>, it generates the appropriate SQL commands to update the database with the changes.</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity">



<h3 class="wp-block-heading"><strong>What Are the Basic Workflow of LINQ to SQL?</strong></h3>



<p class="wp-block-paragraph">The basic workflow of LINQ to SQL follows several key steps that simplify database interaction. Here’s how it typically works:</p>



<h4 class="wp-block-heading"><strong>1. Define Entity Classes:</strong></h4>



<ul class="wp-block-list">
<li><strong>Step 1</strong>: Create <strong>entity classes</strong> that correspond to the tables in your SQL Server database. These classes should have properties that map to the columns in the database.</li>



<li><strong>Example</strong>: </li>
</ul>



<pre class="wp-block-code"><code>public class Customer
{
    public int CustomerID { get; set; }
    public string Name { get; set; }
    public string Email { get; set; }
}
</code></pre>



<h4 class="wp-block-heading"><strong>2. Create a DataContext:</strong></h4>



<ul class="wp-block-list">
<li><strong>Step 2</strong>: Create a <strong>DataContext</strong> object that connects to the database. The DataContext is responsible for querying the database and saving changes.</li>



<li><strong>Example</strong>: </li>
</ul>



<pre class="wp-block-code"><code>var db = new DataContext("connectionString");
</code></pre>



<h4 class="wp-block-heading"><strong>3. Query Data Using LINQ:</strong></h4>



<ul class="wp-block-list">
<li><strong>Step 3</strong>: Use <strong>LINQ queries</strong> to retrieve data from the database. The DataContext translates the LINQ query into SQL.</li>



<li><strong>Example</strong>: </li>
</ul>



<pre class="wp-block-code"><code>var customers = from c in db.GetTable&lt;Customer&gt;()
                where c.Name == "John"
                select c;
</code></pre>



<h4 class="wp-block-heading"><strong>4. Modify Data (CRUD Operations):</strong></h4>



<ul class="wp-block-list">
<li><strong>Step 4</strong>: Use the DataContext to modify the data (CRUD operations).</li>



<li><strong>Example</strong>: </li>
</ul>



<pre class="wp-block-code"><code>var customer = customers.FirstOrDefault();
if (customer != null)
{
    customer.Email = "newemail@example.com";
}
db.SubmitChanges();  // Save changes to the database
</code></pre>



<h4 class="wp-block-heading"><strong>5. Handling Transactions:</strong></h4>



<ul class="wp-block-list">
<li><strong>Step 5</strong>: If necessary, you can use <strong>transactions</strong> to ensure data integrity during multiple operations.</li>



<li><strong>Example</strong>: </li>
</ul>



<pre class="wp-block-code"><code>using (var transaction = db.Connection.BeginTransaction())
{
    try
    {
        // Perform multiple database operations
        db.SubmitChanges();
        transaction.Commit();
    }
    catch
    {
        transaction.Rollback();
    }
}
</code></pre>



<hr class="wp-block-separator has-alpha-channel-opacity">



<h3 class="wp-block-heading"><strong>Step-by-Step Getting Started Guide for LINQ to SQL</strong></h3>



<p class="wp-block-paragraph">Follow these steps to get started with <strong>LINQ to SQL</strong>:</p>



<h4 class="wp-block-heading"><strong>Step 1: Set Up a Database</strong></h4>



<ul class="wp-block-list">
<li>Create a SQL Server database with tables you want to interact with. You can use <strong>SQL Server Management Studio (SSMS)</strong> or other database tools to set up the database.</li>
</ul>



<h4 class="wp-block-heading"><strong>Step 2: Define Entity Classes</strong></h4>



<ul class="wp-block-list">
<li>Create <strong>entity classes</strong> in C# that map to the tables in your database. Use attributes or <strong>LINQ to SQL designer</strong> to automatically generate entity classes.</li>
</ul>



<h4 class="wp-block-heading"><strong>Step 3: Create DataContext</strong></h4>



<ul class="wp-block-list">
<li>Instantiate a <strong>DataContext</strong> that connects to your SQL Server database: </li>
</ul>



<pre class="wp-block-code"><code>var db = new DataContext("your_connection_string");
</code></pre>



<h4 class="wp-block-heading"><strong>Step 4: Query Data</strong></h4>



<ul class="wp-block-list">
<li>Use <strong>LINQ queries</strong> to retrieve data from the database: </li>
</ul>



<pre class="wp-block-code"><code>var customers = from c in db.GetTable&lt;Customer&gt;()
                where c.Name.Contains("John")
                select c;
</code></pre>



<h4 class="wp-block-heading"><strong>Step 5: Perform CRUD Operations</strong></h4>



<ul class="wp-block-list">
<li>Use <strong>CRUD</strong> operations such as <strong>Insert</strong>, <strong>Update</strong>, and <strong>Delete</strong> to modify data in the database.</li>
</ul>



<h4 class="wp-block-heading"><strong>Step 6: Submit Changes</strong></h4>



<ul class="wp-block-list">
<li>Use <strong>SubmitChanges()</strong> to save changes made to the objects back to the database: </li>
</ul>



<pre class="wp-block-code"><code>db.SubmitChanges();
</code></pre>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/mastering-linq-to-sql-use-cases-architecture-workflow-and-getting-started-guide/">Mastering LINQ to SQL: Use Cases, Architecture, Workflow, and Getting Started Guide</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.scmgalaxy.com/tutorials/mastering-linq-to-sql-use-cases-architecture-workflow-and-getting-started-guide/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>In-Depth Guide to NHibernate: Detailed Overview, Architecture, Use Cases, Workflow, and Getting Started</title>
		<link>https://www.scmgalaxy.com/tutorials/in-depth-guide-to-nhibernate-detailed-overview-architecture-use-cases-workflow-and-getting-started/</link>
					<comments>https://www.scmgalaxy.com/tutorials/in-depth-guide-to-nhibernate-detailed-overview-architecture-use-cases-workflow-and-getting-started/#respond</comments>
		
		<dc:creator><![CDATA[Vijay K]]></dc:creator>
		<pubDate>Fri, 27 Jun 2025 12:30:00 +0000</pubDate>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[DatabaseIntegration]]></category>
		<category><![CDATA[DOTNET]]></category>
		<category><![CDATA[EntityFramework]]></category>
		<category><![CDATA[NHibernate]]></category>
		<category><![CDATA[ORM]]></category>
		<category><![CDATA[SoftwareDevelopment]]></category>
		<category><![CDATA[TechEducation]]></category>
		<guid isPermaLink="false">https://www.scmgalaxy.com/tutorials/?p=12995</guid>

					<description><![CDATA[<p>What is NHibernate? NHibernate is an open-source Object-Relational Mapping (ORM) framework for the .NET platform, designed to facilitate the interaction [&#8230;]</p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/in-depth-guide-to-nhibernate-detailed-overview-architecture-use-cases-workflow-and-getting-started/">In-Depth Guide to NHibernate: Detailed Overview, Architecture, Use Cases, Workflow, and Getting Started</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="572" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2025/06/image-213-1024x572.png" alt="" class="wp-image-12998" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2025/06/image-213-1024x572.png 1024w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2025/06/image-213-300x168.png 300w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2025/06/image-213-768x429.png 768w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2025/06/image-213.png 1103w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<hr class="wp-block-separator has-alpha-channel-opacity">



<h3 class="wp-block-heading"><strong>What is NHibernate?</strong></h3>



<p class="wp-block-paragraph"><strong>NHibernate</strong> is an open-source <strong>Object-Relational Mapping (ORM)</strong> framework for the <strong>.NET</strong> platform, designed to facilitate the interaction between object-oriented code and relational databases. As a part of the <strong>NHibernate Project</strong>, it serves as a powerful tool for <strong>mapping .NET objects</strong> to <strong>database tables</strong>, allowing developers to perform <strong>database operations</strong> using object-oriented programming principles instead of SQL.</p>



<p class="wp-block-paragraph">In traditional <strong>relational database systems</strong>, data is represented in tables, rows, and columns, whereas in <strong>object-oriented programming</strong>, data is typically represented as objects with properties and methods. <strong>NHibernate</strong> acts as a bridge between these two paradigms, making it easier for developers to map <strong>.NET classes</strong> to <strong>database tables</strong> and to manage the interactions with the database using <strong>objects</strong> instead of tables and SQL queries.</p>



<p class="wp-block-paragraph">Key features of NHibernate include:</p>



<ul class="wp-block-list">
<li><strong>Mapping Classes to Database Tables</strong>: You can map <strong>C# classes</strong> to <strong>database tables</strong> and <strong>class properties</strong> to <strong>columns</strong> in the tables.</li>



<li><strong>CRUD Operations</strong>: NHibernate simplifies <strong>Create</strong>, <strong>Read</strong>, <strong>Update</strong>, and <strong>Delete</strong> operations, allowing developers to use C# methods instead of writing raw SQL queries.</li>



<li><strong>Automatic Schema Generation</strong>: NHibernate can automatically generate the database schema based on your object model.</li>



<li><strong>Querying and Filtering</strong>: It provides a powerful <strong>query language</strong> (HQL or <strong>Hibernate Query Language</strong>) to perform complex queries using object-oriented syntax.</li>



<li><strong>Lazy Loading</strong>: NHibernate supports <strong>lazy loading</strong>, meaning it only loads related data when it is specifically requested, thus improving performance.</li>



<li><strong>Caching</strong>: Built-in support for <strong>first-level and second-level caching</strong>, which improves the performance of frequently accessed data by reducing database hits.</li>
</ul>



<p class="wp-block-paragraph">Overall, NHibernate allows developers to work more efficiently with relational databases by reducing the need for <strong>manual SQL queries</strong> and enabling <strong>object-oriented</strong> approaches to data management.</p>



<hr class="wp-block-separator has-alpha-channel-opacity">



<h3 class="wp-block-heading"><strong>What Are the Major Use Cases of NHibernate?</strong></h3>



<p class="wp-block-paragraph">NHibernate is primarily used in <strong>enterprise applications</strong>, especially those where <strong>data persistence</strong> and <strong>database management</strong> need to be abstracted and automated. Below are some <strong>major use cases</strong> for NHibernate:</p>



<h4 class="wp-block-heading"><strong>1. Enterprise Application Data Management:</strong></h4>



<ul class="wp-block-list">
<li><strong>Use Case</strong>: NHibernate is widely used in <strong>large-scale enterprise applications</strong> that require persistent data storage and complex relationships between entities.</li>



<li><strong>Example</strong>: A <strong>customer relationship management (CRM)</strong> system where data about customers, orders, products, and interactions are stored and queried frequently.</li>



<li><strong>Why NHibernate?</strong> NHibernate handles complex data models and relationships (like <strong>many-to-many</strong>, <strong>one-to-many</strong>, and <strong>one-to-one</strong>) efficiently by automating data persistence and providing easy-to-use query capabilities.</li>
</ul>



<h4 class="wp-block-heading"><strong>2. Simplifying Data Access Layer:</strong></h4>



<ul class="wp-block-list">
<li><strong>Use Case</strong>: NHibernate is often used to simplify the <strong>data access layer</strong> in .NET applications by abstracting the interaction with the database and eliminating the need for writing extensive SQL queries.</li>



<li><strong>Example</strong>: A <strong>task management system</strong> where developers interact with task objects rather than writing SQL queries to manipulate data in the database.</li>



<li><strong>Why NHibernate?</strong> NHibernate provides a <strong>high-level abstraction</strong>, making it easier for developers to interact with relational data in an <strong>object-oriented</strong> manner. It automates <strong>SQL generation</strong> and <strong>parameter binding</strong> behind the scenes, reducing code complexity.</li>
</ul>



<h4 class="wp-block-heading"><strong>3. Cross-Database Compatibility:</strong></h4>



<ul class="wp-block-list">
<li><strong>Use Case</strong>: NHibernate is also used when <strong>database portability</strong> is required. You can configure NHibernate to work with different relational databases like <strong>SQL Server</strong>, <strong>MySQL</strong>, <strong>PostgreSQL</strong>, <strong>Oracle</strong>, etc., without changing your application code.</li>



<li><strong>Example</strong>: An <strong>e-commerce application</strong> that needs to support multiple database platforms for different deployment environments (development, staging, production).</li>



<li><strong>Why NHibernate?</strong> NHibernate abstracts the interaction with the database, allowing developers to switch database providers easily without modifying their codebase.</li>
</ul>



<h4 class="wp-block-heading"><strong>4. Legacy System Integration:</strong></h4>



<ul class="wp-block-list">
<li><strong>Use Case</strong>: NHibernate can be used to <strong>integrate legacy databases</strong> with modern applications. By mapping existing tables to .NET objects, NHibernate can be used to work with legacy databases that require more modern querying and data manipulation capabilities.</li>



<li><strong>Example</strong>: An organization with an old <strong>SQL-based database</strong> needs to integrate it with a <strong>new web application</strong> using modern development practices and frameworks.</li>



<li><strong>Why NHibernate?</strong> NHibernate allows seamless integration with legacy systems, reducing the overhead involved in migrating or rewriting legacy database access code.</li>
</ul>



<h4 class="wp-block-heading"><strong>5. Complex Querying and Reporting:</strong></h4>



<ul class="wp-block-list">
<li><strong>Use Case</strong>: NHibernate’s <strong>query capabilities</strong>, including the use of <strong>HQL (Hibernate Query Language)</strong> and <strong>LINQ</strong>, make it suitable for applications that require advanced querying, filtering, and reporting features.</li>



<li><strong>Example</strong>: A <strong>reporting system</strong> that aggregates sales data by product, region, and time period, and needs to query the database using <strong>complex filters</strong> and <strong>grouping</strong>.</li>



<li><strong>Why NHibernate?</strong> NHibernate’s <strong>HQL</strong> and <strong>LINQ</strong> provide a flexible and object-oriented way to query data, making it easy to perform complex database operations without writing raw SQL queries.</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity">



<h3 class="wp-block-heading"><strong>How NHibernate Works Along with Architecture?</strong></h3>



<figure class="wp-block-image size-full is-resized"><img loading="lazy" decoding="async" width="600" height="339" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2025/06/image-214.png" alt="" class="wp-image-12999" style="width:820px;height:auto" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2025/06/image-214.png 600w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2025/06/image-214-300x170.png 300w" sizes="auto, (max-width: 600px) 100vw, 600px" /></figure>



<p class="wp-block-paragraph">NHibernate is built on a <strong>layered architecture</strong> that provides abstraction for data access, while integrating with the <strong>.NET object model</strong>. Below is an overview of the architecture and how NHibernate queries work:</p>



<h4 class="wp-block-heading"><strong>1. NHibernate Architecture Overview:</strong></h4>



<ul class="wp-block-list">
<li><strong>SessionFactory</strong>: The <strong>SessionFactory</strong> is the primary configuration object responsible for creating <strong>sessions</strong> that interact with the database. It is initialized once per application and serves as a factory for creating session objects.
<ul class="wp-block-list">
<li><strong>How it Works</strong>: The <strong>SessionFactory</strong> holds configuration information, such as database connection details and entity mappings, which are used to interact with the database.</li>
</ul>
</li>



<li><strong>Session</strong>: The <strong>Session</strong> object provides the interface to interact with the database. It is used to perform CRUD operations and execute queries. Sessions are lightweight, short-lived, and created on demand.
<ul class="wp-block-list">
<li><strong>How it Works</strong>: A session is created from the <strong>SessionFactory</strong> and is used to persist and retrieve objects from the database. It is responsible for managing the <strong>first-level cache</strong> (data cached during a session&#8217;s lifetime).</li>
</ul>
</li>



<li><strong>Transaction</strong>: NHibernate uses <strong>transactions</strong> to ensure that operations on the database are <strong>atomic</strong> and consistent. Each session can have one active transaction at a time.
<ul class="wp-block-list">
<li><strong>How it Works</strong>: Transactions wrap operations and guarantee that changes to the database are either committed or rolled back to maintain data integrity.</li>
</ul>
</li>



<li><strong>Query Engine</strong>: The <strong>query engine</strong> is responsible for executing queries (HQL, LINQ, or Criteria queries) and returning results. NHibernate provides a <strong>powerful query language</strong> called <strong>HQL (Hibernate Query Language)</strong>, which is similar to SQL but works with objects.
<ul class="wp-block-list">
<li><strong>How it Works</strong>: The query engine translates HQL or LINQ queries into <strong>SQL queries</strong>, executes them against the database, and returns the results as <strong>objects</strong>.</li>
</ul>
</li>



<li><strong>Mapping</strong>: NHibernate uses <strong>mapping files</strong> (XML or Fluent API) to map <strong>.NET objects</strong> to <strong>relational database tables</strong>. This mapping defines how the <strong>class properties</strong> correspond to <strong>columns</strong> in a database table.
<ul class="wp-block-list">
<li><strong>How it Works</strong>: When querying or persisting data, NHibernate uses the mapping configuration to translate between <strong>C# objects</strong> and <strong>SQL</strong>.</li>
</ul>
</li>
</ul>



<h4 class="wp-block-heading"><strong>2. NHibernate Query Language (HQL):</strong></h4>



<ul class="wp-block-list">
<li><strong>HQL</strong> is a <strong>query language</strong> for NHibernate that allows developers to write queries that work with <strong>objects</strong> rather than tables and rows. HQL is very similar to SQL but works at the <strong>object level</strong>.</li>



<li><strong>Example</strong>: A basic HQL query to retrieve all <code>Customer</code> objects: </li>
</ul>



<pre class="wp-block-code"><code>var query = session.CreateQuery("from Customer");
var customers = query.List&lt;Customer&gt;();
</code></pre>



<h4 class="wp-block-heading"><strong>3. LINQ to NHibernate:</strong></h4>



<ul class="wp-block-list">
<li><strong>LINQ (Language Integrated Query)</strong> can also be used with NHibernate to write strongly typed queries in C#. NHibernate translates LINQ queries into <strong>SQL</strong> and executes them on the database.</li>



<li><strong>Example</strong>: </li>
</ul>



<pre class="wp-block-code"><code>var customers = session.Query&lt;Customer&gt;().Where(c =&gt; c.Age &gt; 30).ToList();
</code></pre>



<hr class="wp-block-separator has-alpha-channel-opacity">



<h3 class="wp-block-heading"><strong>What Are the Basic Workflow of NHibernate?</strong></h3>



<p class="wp-block-paragraph">The basic workflow of NHibernate involves several key steps to manage data and perform queries. Below is the typical workflow when using NHibernate in a .NET application:</p>



<h4 class="wp-block-heading"><strong>1. Set Up NHibernate Configuration:</strong></h4>



<ul class="wp-block-list">
<li>First, configure NHibernate to define how it should connect to the database and how it should map .NET objects to database tables.</li>



<li><strong>Example (Configuration using XML)</strong>: </li>
</ul>



<pre class="wp-block-code"><code>&lt;hibernate-configuration&gt;
  &lt;session-factory&gt;
    &lt;property name="hibernate.dialect"&gt;NHibernate.Dialect.MsSql2008Dialect&lt;/property&gt;
    &lt;property name="hibernate.connection.driver_class"&gt;NHibernate.Driver.SqlClientDriver&lt;/property&gt;
    &lt;property name="hibernate.connection.connection_string"&gt;YourConnectionString&lt;/property&gt;
  &lt;/session-factory&gt;
&lt;/hibernate-configuration&gt;
</code></pre>



<h4 class="wp-block-heading"><strong>2. Define Mappings:</strong></h4>



<ul class="wp-block-list">
<li>Create mappings between <strong>.NET classes</strong> and <strong>database tables</strong>. You can do this using <strong>XML mapping files</strong> or <strong>Fluent NHibernate</strong>.</li>



<li><strong>Example (Fluent NHibernate Mapping)</strong>: </li>
</ul>



<pre class="wp-block-code"><code>public class CustomerMap : ClassMap&lt;Customer&gt;
{
    public CustomerMap()
    {
        Id(x =&gt; x.Id);
        Map(x =&gt; x.Name);
        Map(x =&gt; x.Email);
        Table("Customers");
    }
}
</code></pre>



<h4 class="wp-block-heading"><strong>3. Open a Session and Start Querying:</strong></h4>



<ul class="wp-block-list">
<li>After setting up the configuration and mappings, you can open a <strong>session</strong> and start querying the database or performing CRUD operations.</li>



<li><strong>Example</strong>: </li>
</ul>



<pre class="wp-block-code"><code>var sessionFactory = new Configuration().Configure().BuildSessionFactory();
using (var session = sessionFactory.OpenSession())
{
    var customers = session.CreateQuery("from Customer").List&lt;Customer&gt;();
}
</code></pre>



<h4 class="wp-block-heading"><strong>4. Perform CRUD Operations:</strong></h4>



<ul class="wp-block-list">
<li>Use the session to <strong>save</strong>, <strong>load</strong>, <strong>update</strong>, and <strong>delete</strong> data. NHibernate takes care of generating the appropriate SQL statements.</li>



<li><strong>Example</strong>: </li>
</ul>



<pre class="wp-block-code"><code>// Save a new customer
session.Save(new Customer { Name = "John", Email = "john@example.com" });
</code></pre>



<h4 class="wp-block-heading"><strong>5. Handle Transactions:</strong></h4>



<ul class="wp-block-list">
<li>Use transactions to ensure consistency and atomicity when performing data operations.</li>



<li><strong>Example</strong>:</li>
</ul>



<pre class="wp-block-code"><code>using (var transaction = session.BeginTransaction())
{
    try
    {
        session.Save(customer);
        transaction.Commit();
    }
    catch
    {
        transaction.Rollback();
    }
}
</code></pre>



<hr class="wp-block-separator has-alpha-channel-opacity">



<h3 class="wp-block-heading"><strong>Step-by-Step Getting Started Guide for NHibernate</strong></h3>



<p class="wp-block-paragraph">Here is a step-by-step guide to get you started with NHibernate:</p>



<h4 class="wp-block-heading"><strong>Step 1: Install NHibernate</strong></h4>



<ul class="wp-block-list">
<li>Install NHibernate via <strong>NuGet</strong> in your .NET project:</li>
</ul>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
Install-Package NHibernate

</pre></div>


<h4 class="wp-block-heading"><strong>Step 2: Set Up NHibernate Configuration</strong></h4>



<ul class="wp-block-list">
<li>Set up <strong>NHibernate configuration</strong> in the <code>hibernate.cfg.xml</code> file or use <strong>Fluent NHibernate</strong> for code-based configuration.</li>
</ul>



<h4 class="wp-block-heading"><strong>Step 3: Define the Data Model</strong></h4>



<ul class="wp-block-list">
<li>Create your <strong>C# classes</strong> and define mappings to <strong>database tables</strong> using either <strong>XML mapping files</strong> or <strong>Fluent NHibernate</strong>.</li>
</ul>



<h4 class="wp-block-heading"><strong>Step 4: Open a Session and Perform CRUD Operations</strong></h4>



<ul class="wp-block-list">
<li>Open a <strong>session</strong> from the <strong>SessionFactory</strong> and use it to perform <strong>CRUD operations</strong> such as <code>Save()</code>, <code>Update()</code>, <code>Delete()</code>, and <code>Load()</code>.</li>
</ul>



<h4 class="wp-block-heading"><strong>Step 5: Handle Transactions</strong></h4>



<ul class="wp-block-list">
<li>Use <strong>transactions</strong> to ensure that data modifications are committed or rolled back as needed.</li>
</ul>



<h4 class="wp-block-heading"><strong>Step 6: Test Your Application</strong></h4>



<ul class="wp-block-list">
<li>Test your application by running the code and verifying that NHibernate is interacting with the database as expected.</li>
</ul>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/in-depth-guide-to-nhibernate-detailed-overview-architecture-use-cases-workflow-and-getting-started/">In-Depth Guide to NHibernate: Detailed Overview, Architecture, Use Cases, Workflow, and Getting Started</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.scmgalaxy.com/tutorials/in-depth-guide-to-nhibernate-detailed-overview-architecture-use-cases-workflow-and-getting-started/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Deep Dive into Entity Framework: Concepts, Architecture, and Getting Started Guide</title>
		<link>https://www.scmgalaxy.com/tutorials/deep-dive-into-entity-framework-concepts-architecture-and-getting-started-guide/</link>
					<comments>https://www.scmgalaxy.com/tutorials/deep-dive-into-entity-framework-concepts-architecture-and-getting-started-guide/#respond</comments>
		
		<dc:creator><![CDATA[Vijay K]]></dc:creator>
		<pubDate>Thu, 15 May 2025 05:37:48 +0000</pubDate>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[DatabaseAccess]]></category>
		<category><![CDATA[DotNetDevelopment]]></category>
		<category><![CDATA[DotNetORM]]></category>
		<category><![CDATA[EFCore]]></category>
		<category><![CDATA[EFWorkflow]]></category>
		<category><![CDATA[EntityFramework]]></category>
		<category><![CDATA[EntityFrameworkArchitecture]]></category>
		<category><![CDATA[LINQ]]></category>
		<guid isPermaLink="false">https://www.scmgalaxy.com/tutorials/?p=12304</guid>

					<description><![CDATA[<p>What is Entity Framework? Entity Framework (EF) is a popular open-source Object-Relational Mapping (ORM) framework developed by Microsoft for the [&#8230;]</p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/deep-dive-into-entity-framework-concepts-architecture-and-getting-started-guide/">Deep Dive into Entity Framework: Concepts, Architecture, and Getting Started Guide</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1000" height="420" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2025/05/image-43.png" alt="" class="wp-image-12307" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2025/05/image-43.png 1000w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2025/05/image-43-300x126.png 300w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2025/05/image-43-768x323.png 768w" sizes="auto, (max-width: 1000px) 100vw, 1000px" /></figure>



<hr class="wp-block-separator has-alpha-channel-opacity">



<h3 class="wp-block-heading">What is Entity Framework?</h3>



<p class="wp-block-paragraph">Entity Framework (EF) is a popular open-source Object-Relational Mapping (ORM) framework developed by Microsoft for the .NET platform. It enables developers to interact with relational databases using .NET objects, abstracting the database access layer and eliminating the need to write raw SQL queries. EF supports working with data as domain-specific objects and properties, allowing a more intuitive and object-oriented approach to database programming.</p>



<p class="wp-block-paragraph">With Entity Framework, developers model their application data as entities and relationships in the code. EF then automatically translates these object operations into SQL commands that interact with the underlying database. It supports various database providers including Microsoft SQL Server, SQLite, PostgreSQL, MySQL, and others.</p>



<p class="wp-block-paragraph">EF simplifies data access and management by providing features like change tracking, lazy loading, eager loading, caching, and migrations, making it easier to develop, maintain, and evolve data-driven applications.</p>



<hr class="wp-block-separator has-alpha-channel-opacity">



<h3 class="wp-block-heading">Major Use Cases of Entity Framework</h3>



<ol class="wp-block-list">
<li><strong>Rapid Application Development</strong><br>EF accelerates development by allowing developers to work directly with objects instead of database tables and SQL, improving productivity and reducing boilerplate code.</li>



<li><strong>Data-Driven Enterprise Applications</strong><br>Large business applications benefit from EF’s ability to handle complex data models, relationships, and business rules while ensuring consistency and data integrity.</li>



<li><strong>Cross-Platform Data Access</strong><br>EF Core, the modern version of EF, supports cross-platform development enabling .NET applications to run on Windows, Linux, and macOS, accessing multiple database systems.</li>



<li><strong>Database-First or Code-First Development</strong><br>EF supports multiple development approaches:
<ul class="wp-block-list">
<li><strong>Database-First:</strong> Generates the model from an existing database.</li>



<li><strong>Code-First:</strong> Creates the database schema based on code definitions.</li>
</ul>
</li>



<li><strong>Migration and Versioning of Databases</strong><br>EF migrations provide a structured way to evolve the database schema alongside application changes, reducing the risks of manual schema modifications.</li>



<li><strong>Simplifying CRUD Operations</strong><br>EF provides high-level APIs to perform create, read, update, and delete operations on entities, handling underlying SQL generation and execution.</li>



<li><strong>Integration with ASP.NET Core</strong><br>Entity Framework integrates seamlessly with ASP.NET Core, powering modern web applications and APIs with efficient data access layers.</li>
</ol>



<hr class="wp-block-separator has-alpha-channel-opacity">



<h3 class="wp-block-heading">How Entity Framework Works Along with Architecture</h3>



<figure class="wp-block-image size-full is-resized"><img loading="lazy" decoding="async" width="462" height="280" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2025/05/image-44.png" alt="" class="wp-image-12308" style="width:822px;height:auto" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2025/05/image-44.png 462w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2025/05/image-44-300x182.png 300w" sizes="auto, (max-width: 462px) 100vw, 462px" /></figure>



<p class="wp-block-paragraph">Entity Framework’s architecture is designed around a layered approach that separates the conceptual data model from the physical database representation:</p>



<p class="wp-block-paragraph"><strong>1. Conceptual Model (Entities and Relationships):</strong><br>This layer defines the entities as classes and their relationships using navigation properties. Developers interact with this model when writing code.</p>



<p class="wp-block-paragraph"><strong>2. Object Services Layer:</strong><br>This layer manages the interaction between the conceptual model and the underlying data. It includes:</p>



<ul class="wp-block-list">
<li><strong>Change Tracker:</strong> Monitors entity state changes (Added, Modified, Deleted).</li>



<li><strong>Object Context / DbContext:</strong> Provides APIs to query and save entity data.</li>
</ul>



<p class="wp-block-paragraph"><strong>3. Mapping Layer:</strong><br>Maps the conceptual model entities and their properties to database tables and columns. This is handled via metadata and configuration.</p>



<p class="wp-block-paragraph"><strong>4. Query Processing:</strong><br>EF translates LINQ (Language Integrated Query) expressions into SQL queries optimized for the target database.</p>



<p class="wp-block-paragraph"><strong>5. Provider Layer:</strong><br>EF communicates with different database providers (SQL Server, SQLite, etc.) through a provider-specific implementation that translates generic commands into database-specific SQL.</p>



<p class="wp-block-paragraph"><strong>6. Database Layer:</strong><br>The physical database where data is stored and managed.</p>



<p class="wp-block-paragraph"><strong>Architecture Diagram (Conceptual):</strong></p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
Application Code (Entities, LINQ Queries)
            ↓
Entity Framework Object Context (DbContext)
            ↓
Mapping &amp;amp; Query Translation
            ↓
Database Provider (SQL Server, SQLite, etc.)
            ↓
Physical Database

</pre></div>


<hr class="wp-block-separator has-alpha-channel-opacity">



<h3 class="wp-block-heading">Basic Workflow of Entity Framework</h3>



<ol class="wp-block-list">
<li><strong>Define the Model:</strong><br>Create entity classes representing tables, define relationships via navigation properties, and configure mappings either by conventions, data annotations, or Fluent API.</li>



<li><strong>Create DbContext:</strong><br>A context class derived from <code>DbContext</code> serves as the gateway for querying and saving data. It exposes <code>DbSet&lt;TEntity&gt;</code> properties representing tables.</li>



<li><strong>Query Data:</strong><br>Use LINQ queries against <code>DbSet</code> collections to retrieve data as strongly typed objects.</li>



<li><strong>Modify Data:</strong><br>Add, update, or delete entities through the context, which tracks changes.</li>



<li><strong>Save Changes:</strong><br>Call <code>SaveChanges()</code> on the context to persist changes to the database, translating changes into SQL statements.</li>



<li><strong>Manage Schema Changes:</strong><br>Use EF migrations to evolve the database schema safely as the model changes.</li>
</ol>



<hr class="wp-block-separator has-alpha-channel-opacity">



<h3 class="wp-block-heading">Step-by-Step Getting Started Guide for Entity Framework</h3>



<p class="wp-block-paragraph"><strong>Step 1: Setup Your Development Environment</strong></p>



<ul class="wp-block-list">
<li>Install Visual Studio or Visual Studio Code with .NET SDK installed.</li>



<li>Create a new .NET Core or .NET Framework project.</li>
</ul>



<p class="wp-block-paragraph"><strong>Step 2: Install Entity Framework Packages</strong><br>For EF Core, install via NuGet Package Manager or CLI:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
dotnet add package Microsoft.EntityFrameworkCore
dotnet add package Microsoft.EntityFrameworkCore.SqlServer  # For SQL Server
dotnet add package Microsoft.EntityFrameworkCore.Tools      # For migrations

</pre></div>


<p class="wp-block-paragraph"><strong>Step 3: Define Entity Classes</strong><br>Create POCO (Plain Old CLR Objects) classes to represent database tables:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
public class Student
{
    public int StudentId { get; set; }
    public string Name { get; set; }
    public DateTime EnrollmentDate { get; set; }
}

</pre></div>


<p class="wp-block-paragraph"><strong>Step 4: Create DbContext Class</strong><br>Create a context class that inherits from <code>DbContext</code>:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
public class SchoolContext : DbContext
{
    public DbSet&amp;lt;Student&amp;gt; Students { get; set; }

    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
    {
        optionsBuilder.UseSqlServer(&quot;YourConnectionStringHere&quot;);
    }
}

</pre></div>


<p class="wp-block-paragraph"><strong>Step 5: Use EF in Application</strong><br>Querying data example:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
using(var context = new SchoolContext())
{
    var students = context.Students.Where(s =&amp;gt; s.Name.StartsWith(&quot;A&quot;)).ToList();
}

</pre></div>


<p class="wp-block-paragraph"><strong>Step 6: Add and Save Data</strong></p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
using(var context = new SchoolContext())
{
    var student = new Student { Name = &quot;John Doe&quot;, EnrollmentDate = DateTime.Now };
    context.Students.Add(student);
    context.SaveChanges();
}

</pre></div>


<p class="wp-block-paragraph"><strong>Step 7: Use Migrations to Create Database</strong><br>Initialize migrations and update database:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
dotnet ef migrations add InitialCreate
dotnet ef database update

</pre></div><p>The post <a href="https://www.scmgalaxy.com/tutorials/deep-dive-into-entity-framework-concepts-architecture-and-getting-started-guide/">Deep Dive into Entity Framework: Concepts, Architecture, and Getting Started Guide</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.scmgalaxy.com/tutorials/deep-dive-into-entity-framework-concepts-architecture-and-getting-started-guide/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
