SlideShare uma empresa Scribd logo
1 de 55
Baixar para ler offline
.NET Core + ASP.NET Core Training Course
Session 16
.NET Core
What we learned?
Session 6 ~ 15 Overview
• ASP.NET Core Basics
• Middleware, Controllers, Action Filters and Routing
• Models
• Views
• Entity Framework Core (Modeling)
• Entity Framework Core (Querying Data)
• Entity Framework Core (Saving Data)
.NET Core
What we’ll learn today?
Session 16 Agenda
• Entity Framework Core (Saving Data)
.NET Core
Announcing .NET Core 1.1 Preview 1
Entity Framework Core – v1.1 Preview 1
Improvements
The .NET Core 1.1 release is the first 1.x minor update. Its primary product theme
is adding support for new operating system distributions. 1380 APIs were added in
this release.
Operating System Distributions
Support for the following distributions was added:
• Linux Mint 18
• OpenSUSE 42.1
• macOS 10.12
• Windows Server 2016
.NET Core
Announcing EF Core 1.1 Preview 1
Entity Framework Core – v1.1 Preview 1
Improved LINQ translation
In the 1.1 release we can see good progress improving the EF Core LINQ provider.
This enables more queries to successfully execute, with more logic being evaluated in
the database (rather than in memory).
DbSet.Find
DbSet.Find(…) is an API that is present in EF6.x and has been one of the more
common requests for EF Core. It allows you to easily query for an entity based on its
primary key value. If the entity is already loaded into the context, then it is returned
without querying the database.
.NET Core
Announcing EF Core 1.1 Preview 1
Entity Framework Core – v1.1 Preview 1
Mapping to fields
The new HasField(…) method in the fluent API allows you to configure a backing
field for a property. This is most commonly done when a property does not have a
setter.
.NET Core
Announcing EF Core 1.1 Preview 1
Entity Framework Core – v1.1 Preview 1
By default, EF will use the field when constructing instances of your entity during a
query, or when it can’t use the property (i.e. it needs to set the value but there is no
property setter). You can change this via the new UsePropertyAccessMode(…) API.
.NET Core
Announcing EF Core 1.1 Preview 1
Entity Framework Core – v1.1 Preview 1
You can also create a property in your model that does not have a corresponding
property in the entity class, but uses a field to store the data in the entity. This is
different from Shadow Properties, where the data is stored in the change tracker.
This would typically be used if the entity class uses methods to get/set values.
You can give EF the name of the field in the Property(…) API. If there is no property
with the given name, then EF will look for a field.
.NET Core
Announcing EF Core 1.1 Preview 1
Entity Framework Core – v1.1 Preview 1
You can also choose to give the property a name, other than the field name. This
name is then used when creating the model, most notably it will be used for the
column name that is mapped to in the database.
.NET Core
Announcing EF Core 1.1 Preview 1
Entity Framework Core – v1.1 Preview 1
You can use the EF.Property(…) method to refer to these properties in a LINQ query.
.NET Core
Announcing EF Core 1.1 Preview 1
Entity Framework Core – v1.1 Preview 1
Explicit Loading
Explicit loading allows you to load the contents of a navigation property for an entity
that is tracked by the context.
.NET Core
Announcing EF Core 1.1 Preview 1
Entity Framework Core – v1.1 Preview 1
Additional EntityEntry APIs from EF6.x
1. Reload()
2. GetModifiedProperties()
3. GetDatabaseValues()
4. etc.
These APIs are most commonly accessed by calling the DbContext.Entry(object
entity) method.
.NET Core
Announcing EF Core 1.1 Preview 1
Entity Framework Core – v1.1 Preview 1
Connection resiliency
Connection resiliency automatically retries failed database commands. This release includes an
execution strategy that is specifically tailored to SQL Server (including SQL Azure). This execution
strategy is included in our SQL Server provider. It is aware of the exception types that can be retried
and has sensible defaults for maximum retries, delay between retries, etc.
.NET Core
Announcing EF Core 1.1 Preview 1
Entity Framework Core – v1.1 Preview 1
Connection resiliency
Connection resiliency automatically retries failed database commands. This release includes
an execution strategy that is specifically tailored to SQL Server (including SQL Azure). This
execution strategy is included in our SQL Server provider. It is aware of the exception types
that can be retried and has sensible defaults for maximum retries, delay between retries, etc.
.NET Core
Announcing EF Core 1.1 Preview 1
Entity Framework Core – v1.1 Preview 1
Connection resiliency
Other database providers may choose to add retry strategies that are tailored to their database. There
is also a mechanism to register a custom execution strategy of your own.
.NET Core
Announcing EF Core 1.1 Preview 1
Entity Framework Core – v1.1 Preview 1
SQL Server memory-optimized table support
Memory-Optimized Tables are a feature of SQL Server. You can now specify that the table an entity is
mapped to is memory-optimized. When using EF Core to create and maintain a database based on
your model (either with migrations or Database.EnsureCreated), a memory-optimized table will be
created for these entities.
.NET Core
Announcing EF Core 1.1 Preview 1
Entity Framework Core – v1.1 Preview 1
Simplified service replacement
In EF Core 1.0 it is possible to replace internal services that EF uses, but this is complicated and
requires you to take control of the dependency injection container that EF uses. In 1.1 we have made
this much simpler, with a ReplaceService(…) method that can be used when configuring the context.
.NET Core
Announcing EF Core 1.1 Preview 1
Entity Framework Core – v1.1 Preview 1
Simplified service replacement
In EF Core 1.0 it is possible to replace internal services that EF uses, but this is complicated and
requires you to take control of the dependency injection container that EF uses. In 1.1 we have made
this much simpler, with a ReplaceService(…) method that can be used when configuring the context.
.NET Core
EF Core vs. EF6.x
Entity Framework Core vs Entity Framework 6.x
Which One Is Right for You? What is EF6.x?
Entity Framework 6.x (EF6.x) is a tried and tested data access technology with many years of features
and stabilization. It first released in 2008, as part of .NET Framework 3.5 SP1 and Visual Studio 2008
SP1. Starting with the EF4.1 release it has shipped as the EntityFramework NuGet package - currently
the most popular package on NuGet.org.
EF6.x continues to be a supported product, and will continue to see bug fixes and minor
improvements for some time to come.
.NET Core
EF Core vs. EF6.x
Entity Framework Core vs Entity Framework 6.x
Which One Is Right for You? What is EF Core?
Entity Framework Core (EF Core) is a lightweight, extensible, and cross-platform version of Entity
Framework. EF Core introduces many improvements and new features when compared with EF6.x. At
the same time, EF Core is a new code base and very much a v1 product.
EF Core keeps the developer experience from EF6.x, and most of the top-level APIs remain the same
too, so EF Core will feel very familiar to folks who have used EF6.x. At the same time, EF Core is built
over a completely new set of core components. This means EF Core doesn’t automatically inherit all
the features from EF6.x. Some of these features will show up in future releases (such as lazy loading),
other less commonly used features will not be implemented in EF Core.
.NET Core
EF Core vs. EF6.x
Entity Framework Core vs Entity Framework 6.x
Which One Is Right for You? What is EF Core?
Entity Framework Core (EF Core) is a lightweight, extensible, and cross-platform version of Entity
Framework. EF Core introduces many improvements and new features when compared with EF6.x. At
the same time, EF Core is a new code base and very much a v1 product.
EF Core keeps the developer experience from EF6.x, and most of the top-level APIs remain the same
too, so EF Core will feel very familiar to folks who have used EF6.x. At the same time, EF Core is built
over a completely new set of core components. This means EF Core doesn’t automatically inherit all
the features from EF6.x. Some of these features will show up in future releases (such as lazy loading),
other less commonly used features will not be implemented in EF Core.
The new, extensible, and lightweight core has also allowed us to add some features to EF Core that will not be
implemented in EF6.x (such as alternate keys and mixed client/database evaluation in LINQ queries).
.NET Core
EF Core vs. EF6.x
Entity Framework Core vs Entity Framework 6.x
Guidance for new applications
Because EF Core is a new product, and still lacks some critical O/RM features, EF6.x will still be the
most suitable choice for many applications.
These are the types of applications we would recommend using EF Core for.
• New applications that do not require features that are not yet implemented in EF Core. Review
Feature Comparison to see if EF Core may be a suitable choice for your application.
• Applications that target .NET Core, such as Universal Windows Platform (UWP) and ASP.NET
Core applications. These applications can not use EF6.x as it requires the Full .NET Framework
(i.e. .NET Framework 4.5).
.NET Core
EF Core vs. EF6.x
Entity Framework Core vs Entity Framework 6.x
Guidance for existing EF6.x applications
Because of the fundamental changes in EF Core we do not recommend attempting to move an EF6.x
application to EF Core unless you have a compelling reason to make the change. If you want to move
to EF Core to make use of new features, then make sure you are aware of its limitations before you
start.
.NET Core
EF Core vs. EF6.x
Entity Framework Core vs Entity Framework 6.x
Feature Comparison, Features not in EF Core
• Creating a Model
• Complex/value types are types that do not have a primary key and are used to represent a set
of properties on an entity type.
• Visualizing a model to see a graphical representation of the code-based model.
• Simple type conversions such as string => xml.
• Spatial data types such as SQL Server’s geography & geometry.
• Many-to-many relationships without join entity. You can already model a many-to-many
relationship with a join entity, see Relationships for details.
• Alternate inheritance mapping patterns for relational databases, such as table per type (TPT)
and table per concrete type (TPC). Table per hierarchy (TPH) is already supported.
.NET Core
EF Core vs. EF6.x
Entity Framework Core vs Entity Framework 6.x
Feature Comparison, Features not in EF Core
• Querying Data
• Improved translation to enable more queries to successfully execute, with more logic being
evaluated in the database (rather than in-memory).
• GroupBy translation in particular will move translation of the LINQ GroupBy operator to the
database, rather than in-memory.
• Lazy loading enables navigation properties to be automatically populated from the database
when they are accessed.
• Raw SQL queries for non-model types allows a raw SQL query to be used to populate types
that are not part of the model (typically for denormalized view-model data).
.NET Core
EF Core vs. EF6.x
Entity Framework Core vs Entity Framework 6.x
Feature Comparison, Features not in EF Core
• Saving Data
• Simple command interception provides an easy way to read/write commands before/after they
are sent to the database.
• Missing EntityEntry APIs from EF6.x such as Reload, GetModifiedProperties, GetDatabaseValues etc.
• Stored procedure mapping allows EF to use stored procedures to persist changes to the
database (FromSql already provides good support for using a stored procedure to query, see
Raw SQL Queries for details).
.NET Core
EF Core vs. EF6.x
Entity Framework Core vs Entity Framework 6.x
Feature Comparison, Features not in EF Core
• Database Schema Management
• Visual Studio wizard for reverse engineer that allows you to visually configure connection,
select tables, etc. when creating a model from an existing database.
• Update model from database allows a model that was previously reverse engineered from the
database to be refreshed with changes made to the schema.
• Seed data allows a set of data to be easily upserted to the database.
.NET Core
Porting from EF6.x to EF Core
Entity Framework Core vs Entity Framework 6.x
Ensure EF Core Will Work for Your Application
• Missing features
• Behavior changes
• DbSet.Add/Attach and graph behavior
In EF6.x, calling DbSet.Add() on an entity results in a recursive search for all entities
referenced in its navigation properties. Any entities that are found, and are not already
tracked by the context, are also be marked as added. DbSet.Attach() behaves the same,
except all entities are marked as unchanged.
.NET Core
Porting from EF6.x to EF Core
Entity Framework Core vs Entity Framework 6.x
Ensure EF Core Will Work for Your Application
• DbSet.Add/Attach and graph behavior
EF Core performs a similar recursive search, but with some slightly different rules.
• The root entity is always in the requested state (added for DbSet.Add and unchanged
for DbSet.Attach).
• For entities that are found during the recursive search of navigation properties:
• If the primary key of the entity is store generated
• If the primary key is not set to a value, the state is set to added. The primary key value is
considered “not set” if it is assigned the CLR default value for the property type (i.e. 0 for int,
null for string, etc.).
• If the primary key is set to a value, the state is set to unchanged.
• If the primary key is not database generated, the entity is put in the same state as the root.
.NET Core
Porting from EF6.x to EF Core
Entity Framework Core vs Entity Framework 6.x
Ensure EF Core Will Work for Your Application
• Code First database initialization
EF6.x has a significant amount of magic it performs around selecting the database
connection and initializing the database. Some of these rules include:
• If no configuration is performed, EF6.x will select a database on SQL Express or LocalDb.
• If a connection string with the same name as the context is in the applications
App/Web.config file, this connection will be used.
• If the database does not exist, it is created.
• If none of the tables from the model exist in the database, the schema for the current
model is added to the database. If migrations are enabled, then they are used to create the
database.
.NET Core
Porting from EF6.x to EF Core
Entity Framework Core vs Entity Framework 6.x
Ensure EF Core Will Work for Your Application
• Code First table naming convention
• EF6.x runs the entity class name through a pluralization service to calculate the default
table name that the entity is mapped to.
• EF Core uses the name of the DbSet property that the entity is exposed in on the derived
context. If the entity does not have a DbSet property, then the class name is used.
.NET Core
Porting from EF6.x to EF Core
Entity Framework Core vs Entity Framework 6.x
Porting an EDMX-Based Model (Model First & Database First)
EF Core does not support the EDMX file format for models. The best option to port these
models, is to generate a new code-based model from the database for your application.
Install EF Core NuGet packages:
Install the Microsoft.EntityFrameworkCore.Tools NuGet package.
You also need to install the design time NuGet package for the database provider you
want to use. This is typically the runtime database provider package name with .Design
post-fixed. For example, when targeting SQL Server, you would install
Microsoft.EntityFrameworkCore.SqlServer.Design.
.NET Core
Porting from EF6.x to EF Core
Entity Framework Core vs Entity Framework 6.x
Porting an EDMX-Based Model (Model First & Database First)
Regenerate the model
You can now use the reverse engineer functionality to create a model based on your existing
database.
Run the following command in Package Manager Console (Tools –> NuGet Package Manager
–> Package Manager Console). See Package Manager Console (Visual Studio) for command
options to scaffold a subset of tables etc.
Scaffold-DbContext "<connection string>" <database provider name>
.NET Core
Porting from EF6.x to EF Core
Entity Framework Core vs Entity Framework 6.x
Porting an EDMX-Based Model (Model First & Database First)
Regenerate the model
You can now use the reverse engineer functionality to create a model based on your existing
database.
Run the following command in Package Manager Console (Tools –> NuGet Package Manager
–> Package Manager Console). See Package Manager Console (Visual Studio) for command
options to scaffold a subset of tables etc.
Scaffold-DbContext "<connection string>" <database provider name>
Scaffold-DbContext "Server=(localdb)mssqllocaldb;Database=Blogging;Trusted_Connection=True;"
Microsoft.EntityFrameworkCore.SqlServer
.NET Core
Porting from EF6.x to EF Core
Entity Framework Core vs Entity Framework 6.x
Porting a Code-Based Model (Code First & Code First to Existing Database)
Install EF Core NuGet packages
To use EF Core, you install the NuGet package for the database provider you want to use. For
example, when targeting SQL Server, you would install Microsoft.EntityFrameworkCore.SqlServer.
If you are planning to use migrations, then you should also install the
Microsoft.EntityFrameworkCore.Tools package.
It is fine to leave the EF6.x NuGet package (EntityFramework) installed, as EF Core and EF6.x can
be used side-by-side in the same application. However, if you aren’t intending to use EF6.x in any
areas of your application, then uninstalling the package will help give compile errors on pieces of
code that need attention.
.NET Core
Porting from EF6.x to EF Core
Entity Framework Core vs Entity Framework 6.x
Porting a Code-Based Model (Code First & Code First to Existing Database)
Swap namespaces
Most APIs that you use in EF6.x are in the System.Data.Entity namespace (and related sub-
namespaces). The first code change is to swap to the Microsoft.EntityFrameworkCore namespace.
You would typically start with your derived context code file and then work out from there,
addressing compilation errors as they occur.
Context configuration (connection etc.)
EF Core has less magic around detecting the database to connect to. You will need to
override the OnConfiguring method on your derived context, and use the database provider
specific API to setup the connection to the database.
.NET Core
Porting from EF6.x to EF Core
Entity Framework Core vs Entity Framework 6.x
Porting a Code-Based Model (Code First & Code First to Existing Database)
Context configuration (connection etc.)
Most EF6.x applications store the connection string in the applications App/Web.config file. In EF Core,
you read this connection string using the ConfigurationManager API. You may need to add a reference
to the System.Configuration framework assembly to be able to use this API.
.NET Core
Porting from EF6.x to EF Core
Entity Framework Core vs Entity Framework 6.x
Porting a Code-Based Model (Code First & Code First to Existing Database)
Existing migrations
There isn’t really a feasible way to port existing EF6.x migrations to EF Core.
If possible, it is best to assume that all previous migrations from EF6.x have been applied to the
database and then start migrating the schema from that point using EF Core. To do this, you would
use the Add-Migration command to add a migration once the model is ported to EF Core. You would
then remove all code from the Up and Down methods of the scaffolded migration. Subsequent
migrations will compare to the model when that initial migration was scaffolded.
.NET Core
Miscellaneous, Connection Strings
Entity Framework Core Miscellaneous Topics
Most database providers require some form of connection string to connect to the
database. Sometimes this connection string contains sensitive information that needs to
be protected. You may also need to change the connection string as you move your
application between environments, such as development, testing, and production.
.NET Core
Miscellaneous, Connection Strings
Entity Framework Core Miscellaneous Topics
Full .NET Applications
Full .NET applications, such as WinForms, WPF, Console, and ASP.NET 4, have a tried
and tested connection string pattern. The connection string should be added to your
applications App.config file (Web.config if you are using ASP.NET). If your connection
string contains sensitive information, such as username and password, you can protect
the contents of the configuration file using Protected Configuration.
.NET Core
Miscellaneous, Connection Strings
Entity Framework Core Miscellaneous Topics
Full .NET Applications
You can then read the connection string using the ConfigurationManager API in your
context’s OnConfiguring method. You may need to add a reference to the
System.Configuration framework assembly to be able to use this API.
.NET Core
Miscellaneous, Connection Strings
Entity Framework Core Miscellaneous Topics
ASP.NET Core
In ASP.NET Core the configuration system is very flexible, and the connection string
could be stored in appsettings.json, an environment variable, the user secret store, or
another configuration source. See the Configuration section of the ASP.NET Core
documentation for more details. The following example shows the connection string
stored in appsettings.json.
.NET Core
Miscellaneous, Connection Strings
Entity Framework Core Miscellaneous Topics
ASP.NET Core
The context is typically configured in Startup.cs with the connection string being read
from configuration. Note the GetConnectionString() method simply looks for a
configuration value whose key is ConnectionStrings:<connection string name>.
.NET Core
Miscellaneous, Logging
Entity Framework Core Miscellaneous Topics
Create a logger
The first step is to create an implementation of ILoggerProvider and ILogger.
ILoggerProvider is the component that decides when to create instances of your logger(s). The
provider may choose to create different loggers in different situations.
ILogger is the component that does the actual logging. It will be passed information from the
framework when certain events occur.
.NET Core
Miscellaneous, Logger
Entity Framework Core Miscellaneous Topics
Register logger, ASP.NET Core
In an ASP.NET Core application, you register your logger in the Configure method of
Startup.cs:
.NET Core
Miscellaneous, Logger
Entity Framework Core Miscellaneous Topics
Register logger, Other applications
In your application startup code, create and instance of you context and register your
logger.
You only need to register the logger with a single context instance. Once you have
registered it, it will be used for all other instances of the context in the same
AppDomain.
.NET Core
Miscellaneous, Logger
Entity Framework Core Miscellaneous Topics
Filtering what is logged
The easiest way to filter what is logged, is to adjust your logger provider to only return
your logger for certain categories of events. For EF, the category passed to your logger
provider will be the type name of the component that is logging the event.
For example, here is a logger provider that returns the logger only for events related to
executing SQL against a relational database. For all other categories of events, a null
logger (which does nothing) is returned.
.NET Core
Miscellaneous, Using DbContext with dependency injection
Entity Framework Core Miscellaneous Topics
EF supports using DbContext with a dependency injection container. Your DbContext
type can be added to the service container by using AddDbContext<TContext>.
AddDbContext will add make both your DbContext type, TContext, and
DbContextOptions<TContext> to the available for injection from the service container.
.NET Core
Miscellaneous, Using DbContext with dependency injection
Entity Framework Core Miscellaneous Topics
EF supports using DbContext with a dependency injection container. Your DbContext
type can be added to the service container by using AddDbContext<TContext>.
AddDbContext will add make both your DbContext type, TContext, and
DbContextOptions<TContext> to the available for injection from the service container.
.NET Core
Miscellaneous, Using DbContext with dependency injection
Entity Framework Core Miscellaneous Topics
.NET Core
Miscellaneous, Using DbContext with dependency injection
Entity Framework Core Miscellaneous Topics
Using IDbContextFactory<TContext>
As an alternative to the options above, you may also provide an implementation of
IDbContextFactory<TContext>. EF command line tools and dependency injection can use this
factory to create an instance of your DbContext. This may be required in order to enable
specific design-time experiences such as migrations.
Implement this interface to enable design-time services for context types that do not have a
public default constructor. Design-time services will automatically discover implementations
of this interface that are in the same assembly as the derived context.
.NET Core
Miscellaneous, Using DbContext with dependency injection
Entity Framework Core Miscellaneous Topics
.NET Core
Understanding EF Services
Entity Framework Core Miscellaneous Topics
Entity Framework executes as a collection of services working together. A service is a
reusable component. A service is typically an implementation of an interface. Services
are available to other services via dependency injection (DI), which is implemented in
EF using Microsoft.Extensions.DependencyInjection.
.NET Core
Understanding EF Services, Terms
Entity Framework Core Miscellaneous Topics
• Service
A reusable component. In .NET, a service can be identified by a class or interface. By convention,
Entity Framework only uses interfaces to identify services.
• Service lifetime
A description of the way in which a service is persisted and disposed across multiple uses of the
same service type.
• Service provider
The mechanism for storing a collection of services. Also known as a service container.
• Service collection
The mechanism for constructing a service provider.
.NET Core
Demo
Demo

Mais conteúdo relacionado

Mais procurados

.NET Core, ASP.NET Core Course, Session 8
.NET Core, ASP.NET Core Course, Session 8.NET Core, ASP.NET Core Course, Session 8
.NET Core, ASP.NET Core Course, Session 8aminmesbahi
 
.NET Core, ASP.NET Core Course, Session 19
 .NET Core, ASP.NET Core Course, Session 19 .NET Core, ASP.NET Core Course, Session 19
.NET Core, ASP.NET Core Course, Session 19aminmesbahi
 
.NET Core, ASP.NET Core Course, Session 17
.NET Core, ASP.NET Core Course, Session 17.NET Core, ASP.NET Core Course, Session 17
.NET Core, ASP.NET Core Course, Session 17aminmesbahi
 
.NET Core, ASP.NET Core Course, Session 6
.NET Core, ASP.NET Core Course, Session 6.NET Core, ASP.NET Core Course, Session 6
.NET Core, ASP.NET Core Course, Session 6aminmesbahi
 
.NET Core, ASP.NET Core Course, Session 3
.NET Core, ASP.NET Core Course, Session 3.NET Core, ASP.NET Core Course, Session 3
.NET Core, ASP.NET Core Course, Session 3aminmesbahi
 
.NET Core, ASP.NET Core Course, Session 2
.NET Core, ASP.NET Core Course, Session 2.NET Core, ASP.NET Core Course, Session 2
.NET Core, ASP.NET Core Course, Session 2aminmesbahi
 
.NET Core, ASP.NET Core Course, Session 1
.NET Core, ASP.NET Core Course, Session 1.NET Core, ASP.NET Core Course, Session 1
.NET Core, ASP.NET Core Course, Session 1aminmesbahi
 
Share point review qustions
Share point review qustionsShare point review qustions
Share point review qustionsthan sare
 
Different Types of Containers in Spring
Different Types of Containers in Spring Different Types of Containers in Spring
Different Types of Containers in Spring Sunil kumar Mohanty
 
Integrating Servlets and JSP (The MVC Architecture)
Integrating Servlets and JSP  (The MVC Architecture)Integrating Servlets and JSP  (The MVC Architecture)
Integrating Servlets and JSP (The MVC Architecture)Amit Ranjan
 
Leverage Hibernate and Spring Features Together
Leverage Hibernate and Spring Features TogetherLeverage Hibernate and Spring Features Together
Leverage Hibernate and Spring Features TogetherEdureka!
 
Spring hibernate tutorial
Spring hibernate tutorialSpring hibernate tutorial
Spring hibernate tutorialRohit Jagtap
 
Java Servlets
Java ServletsJava Servlets
Java ServletsNitin Pai
 
Types of Dependency Injection in Spring
Types of Dependency Injection in SpringTypes of Dependency Injection in Spring
Types of Dependency Injection in SpringSunil kumar Mohanty
 
Mike Taulty OData (NxtGen User Group UK)
Mike Taulty OData (NxtGen User Group UK)Mike Taulty OData (NxtGen User Group UK)
Mike Taulty OData (NxtGen User Group UK)ukdpe
 

Mais procurados (20)

.NET Core, ASP.NET Core Course, Session 8
.NET Core, ASP.NET Core Course, Session 8.NET Core, ASP.NET Core Course, Session 8
.NET Core, ASP.NET Core Course, Session 8
 
.NET Core, ASP.NET Core Course, Session 19
 .NET Core, ASP.NET Core Course, Session 19 .NET Core, ASP.NET Core Course, Session 19
.NET Core, ASP.NET Core Course, Session 19
 
.NET Core, ASP.NET Core Course, Session 17
.NET Core, ASP.NET Core Course, Session 17.NET Core, ASP.NET Core Course, Session 17
.NET Core, ASP.NET Core Course, Session 17
 
.NET Core, ASP.NET Core Course, Session 6
.NET Core, ASP.NET Core Course, Session 6.NET Core, ASP.NET Core Course, Session 6
.NET Core, ASP.NET Core Course, Session 6
 
.NET Core, ASP.NET Core Course, Session 3
.NET Core, ASP.NET Core Course, Session 3.NET Core, ASP.NET Core Course, Session 3
.NET Core, ASP.NET Core Course, Session 3
 
.NET Core, ASP.NET Core Course, Session 2
.NET Core, ASP.NET Core Course, Session 2.NET Core, ASP.NET Core Course, Session 2
.NET Core, ASP.NET Core Course, Session 2
 
.NET Core, ASP.NET Core Course, Session 1
.NET Core, ASP.NET Core Course, Session 1.NET Core, ASP.NET Core Course, Session 1
.NET Core, ASP.NET Core Course, Session 1
 
Share point review qustions
Share point review qustionsShare point review qustions
Share point review qustions
 
Maven
MavenMaven
Maven
 
Spring core
Spring coreSpring core
Spring core
 
Different Types of Containers in Spring
Different Types of Containers in Spring Different Types of Containers in Spring
Different Types of Containers in Spring
 
Spring MVC 5 & Hibernate 5 Integration
Spring MVC 5 & Hibernate 5 IntegrationSpring MVC 5 & Hibernate 5 Integration
Spring MVC 5 & Hibernate 5 Integration
 
Integrating Servlets and JSP (The MVC Architecture)
Integrating Servlets and JSP  (The MVC Architecture)Integrating Servlets and JSP  (The MVC Architecture)
Integrating Servlets and JSP (The MVC Architecture)
 
Leverage Hibernate and Spring Features Together
Leverage Hibernate and Spring Features TogetherLeverage Hibernate and Spring Features Together
Leverage Hibernate and Spring Features Together
 
Spring hibernate tutorial
Spring hibernate tutorialSpring hibernate tutorial
Spring hibernate tutorial
 
Java Servlets
Java ServletsJava Servlets
Java Servlets
 
Spring & hibernate
Spring & hibernateSpring & hibernate
Spring & hibernate
 
Types of Dependency Injection in Spring
Types of Dependency Injection in SpringTypes of Dependency Injection in Spring
Types of Dependency Injection in Spring
 
Mike Taulty OData (NxtGen User Group UK)
Mike Taulty OData (NxtGen User Group UK)Mike Taulty OData (NxtGen User Group UK)
Mike Taulty OData (NxtGen User Group UK)
 
Jsp servlets
Jsp servletsJsp servlets
Jsp servlets
 

Semelhante a .NET Core, ASP.NET Core Course, Session 16

A Tour of EF Core's (1.1) Most Interesting & Important Features
A Tour of EF Core's (1.1) Most Interesting & Important FeaturesA Tour of EF Core's (1.1) Most Interesting & Important Features
A Tour of EF Core's (1.1) Most Interesting & Important FeaturesJulie Lerman
 
EF6 or EF Core? How Do I Choose?
EF6 or EF Core? How Do I Choose?EF6 or EF Core? How Do I Choose?
EF6 or EF Core? How Do I Choose?Julie Lerman
 
Leverage Entity Framework 7 in Business Application Design
Leverage Entity Framework 7 in Business Application Design Leverage Entity Framework 7 in Business Application Design
Leverage Entity Framework 7 in Business Application Design WinWire Technologies Inc
 
.NET on Linux: Entity Framework Core 1.0
.NET on Linux: Entity Framework Core 1.0.NET on Linux: Entity Framework Core 1.0
.NET on Linux: Entity Framework Core 1.0All Things Open
 
Entity Framework 4 In Microsoft Visual Studio 2010
Entity Framework 4 In Microsoft Visual Studio 2010Entity Framework 4 In Microsoft Visual Studio 2010
Entity Framework 4 In Microsoft Visual Studio 2010Eric Nelson
 
.Net Core Blimey! (16/07/2015)
.Net Core Blimey! (16/07/2015).Net Core Blimey! (16/07/2015)
.Net Core Blimey! (16/07/2015)citizenmatt
 
Entity Framework 4 In Microsoft Visual Studio 2010 - ericnel
Entity Framework 4 In Microsoft Visual Studio 2010 - ericnelEntity Framework 4 In Microsoft Visual Studio 2010 - ericnel
Entity Framework 4 In Microsoft Visual Studio 2010 - ericnelukdpe
 
Using entity framework core in .net
Using entity framework core in .netUsing entity framework core in .net
Using entity framework core in .netSophie Obomighie
 
Applying EF Code First at Your Job
Applying EF Code First at Your JobApplying EF Code First at Your Job
Applying EF Code First at Your JobEnea Gabriel
 
Getting Started with SQL Server Compact Edition 3.51
Getting Started with SQL Server Compact Edition 3.51Getting Started with SQL Server Compact Edition 3.51
Getting Started with SQL Server Compact Edition 3.51Mark Ginnebaugh
 
Getting Started with Sql Server Compact Edition
Getting Started with Sql Server Compact EditionGetting Started with Sql Server Compact Edition
Getting Started with Sql Server Compact EditionDonRobins
 
New features of entity framework 7
New features of entity framework 7New features of entity framework 7
New features of entity framework 7Mindfire LLC
 
Dive into .Net Core framework
Dive into .Net Core framework Dive into .Net Core framework
Dive into .Net Core framework ElifTech
 
.net Core Blimey - Smart Devs UG
.net Core Blimey - Smart Devs UG.net Core Blimey - Smart Devs UG
.net Core Blimey - Smart Devs UGcitizenmatt
 
Office OpenXML: a technical approach for OOo.
Office OpenXML: a technical approach for OOo.Office OpenXML: a technical approach for OOo.
Office OpenXML: a technical approach for OOo.Alexandro Colorado
 

Semelhante a .NET Core, ASP.NET Core Course, Session 16 (20)

A Tour of EF Core's (1.1) Most Interesting & Important Features
A Tour of EF Core's (1.1) Most Interesting & Important FeaturesA Tour of EF Core's (1.1) Most Interesting & Important Features
A Tour of EF Core's (1.1) Most Interesting & Important Features
 
EF6 or EF Core? How Do I Choose?
EF6 or EF Core? How Do I Choose?EF6 or EF Core? How Do I Choose?
EF6 or EF Core? How Do I Choose?
 
Leverage Entity Framework 7 in Business Application Design
Leverage Entity Framework 7 in Business Application Design Leverage Entity Framework 7 in Business Application Design
Leverage Entity Framework 7 in Business Application Design
 
Deep Dive into Entity Framework 6.0
Deep Dive into Entity Framework 6.0Deep Dive into Entity Framework 6.0
Deep Dive into Entity Framework 6.0
 
EF Core (RC2)
EF Core (RC2)EF Core (RC2)
EF Core (RC2)
 
.NET on Linux: Entity Framework Core 1.0
.NET on Linux: Entity Framework Core 1.0.NET on Linux: Entity Framework Core 1.0
.NET on Linux: Entity Framework Core 1.0
 
Ef code first
Ef code firstEf code first
Ef code first
 
Entity Framework 4 In Microsoft Visual Studio 2010
Entity Framework 4 In Microsoft Visual Studio 2010Entity Framework 4 In Microsoft Visual Studio 2010
Entity Framework 4 In Microsoft Visual Studio 2010
 
.Net Core Blimey! (16/07/2015)
.Net Core Blimey! (16/07/2015).Net Core Blimey! (16/07/2015)
.Net Core Blimey! (16/07/2015)
 
Entity Framework 4
Entity Framework 4Entity Framework 4
Entity Framework 4
 
Entity Framework 4 In Microsoft Visual Studio 2010 - ericnel
Entity Framework 4 In Microsoft Visual Studio 2010 - ericnelEntity Framework 4 In Microsoft Visual Studio 2010 - ericnel
Entity Framework 4 In Microsoft Visual Studio 2010 - ericnel
 
Entity Framework
Entity FrameworkEntity Framework
Entity Framework
 
Using entity framework core in .net
Using entity framework core in .netUsing entity framework core in .net
Using entity framework core in .net
 
Applying EF Code First at Your Job
Applying EF Code First at Your JobApplying EF Code First at Your Job
Applying EF Code First at Your Job
 
Getting Started with SQL Server Compact Edition 3.51
Getting Started with SQL Server Compact Edition 3.51Getting Started with SQL Server Compact Edition 3.51
Getting Started with SQL Server Compact Edition 3.51
 
Getting Started with Sql Server Compact Edition
Getting Started with Sql Server Compact EditionGetting Started with Sql Server Compact Edition
Getting Started with Sql Server Compact Edition
 
New features of entity framework 7
New features of entity framework 7New features of entity framework 7
New features of entity framework 7
 
Dive into .Net Core framework
Dive into .Net Core framework Dive into .Net Core framework
Dive into .Net Core framework
 
.net Core Blimey - Smart Devs UG
.net Core Blimey - Smart Devs UG.net Core Blimey - Smart Devs UG
.net Core Blimey - Smart Devs UG
 
Office OpenXML: a technical approach for OOo.
Office OpenXML: a technical approach for OOo.Office OpenXML: a technical approach for OOo.
Office OpenXML: a technical approach for OOo.
 

Mais de aminmesbahi

How to choose appropriate technology for product development - Persian Version
How to choose appropriate technology for product development - Persian VersionHow to choose appropriate technology for product development - Persian Version
How to choose appropriate technology for product development - Persian Versionaminmesbahi
 
How to choose appropriate technology for product development
How to choose appropriate technology for product developmentHow to choose appropriate technology for product development
How to choose appropriate technology for product developmentaminmesbahi
 
Python + Machine Learning Course, Session 2
Python + Machine Learning Course, Session 2Python + Machine Learning Course, Session 2
Python + Machine Learning Course, Session 2aminmesbahi
 
Python + Machine Learning Course, Session 1
Python + Machine Learning Course, Session 1Python + Machine Learning Course, Session 1
Python + Machine Learning Course, Session 1aminmesbahi
 
.NET Core, ASP.NET Core Course, Session 9
.NET Core, ASP.NET Core Course, Session 9.NET Core, ASP.NET Core Course, Session 9
.NET Core, ASP.NET Core Course, Session 9aminmesbahi
 
.NET Core, ASP.NET Core Course, Session 5
.NET Core, ASP.NET Core Course, Session 5.NET Core, ASP.NET Core Course, Session 5
.NET Core, ASP.NET Core Course, Session 5aminmesbahi
 
.NET Core, ASP.NET Core Course, Session 4
.NET Core, ASP.NET Core Course, Session 4.NET Core, ASP.NET Core Course, Session 4
.NET Core, ASP.NET Core Course, Session 4aminmesbahi
 
A comparative study of process templates in team
A comparative study of process templates in teamA comparative study of process templates in team
A comparative study of process templates in teamaminmesbahi
 
SQL server 2016 New Features
SQL server 2016 New FeaturesSQL server 2016 New Features
SQL server 2016 New Featuresaminmesbahi
 

Mais de aminmesbahi (9)

How to choose appropriate technology for product development - Persian Version
How to choose appropriate technology for product development - Persian VersionHow to choose appropriate technology for product development - Persian Version
How to choose appropriate technology for product development - Persian Version
 
How to choose appropriate technology for product development
How to choose appropriate technology for product developmentHow to choose appropriate technology for product development
How to choose appropriate technology for product development
 
Python + Machine Learning Course, Session 2
Python + Machine Learning Course, Session 2Python + Machine Learning Course, Session 2
Python + Machine Learning Course, Session 2
 
Python + Machine Learning Course, Session 1
Python + Machine Learning Course, Session 1Python + Machine Learning Course, Session 1
Python + Machine Learning Course, Session 1
 
.NET Core, ASP.NET Core Course, Session 9
.NET Core, ASP.NET Core Course, Session 9.NET Core, ASP.NET Core Course, Session 9
.NET Core, ASP.NET Core Course, Session 9
 
.NET Core, ASP.NET Core Course, Session 5
.NET Core, ASP.NET Core Course, Session 5.NET Core, ASP.NET Core Course, Session 5
.NET Core, ASP.NET Core Course, Session 5
 
.NET Core, ASP.NET Core Course, Session 4
.NET Core, ASP.NET Core Course, Session 4.NET Core, ASP.NET Core Course, Session 4
.NET Core, ASP.NET Core Course, Session 4
 
A comparative study of process templates in team
A comparative study of process templates in teamA comparative study of process templates in team
A comparative study of process templates in team
 
SQL server 2016 New Features
SQL server 2016 New FeaturesSQL server 2016 New Features
SQL server 2016 New Features
 

Último

Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 

Último (20)

Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 

.NET Core, ASP.NET Core Course, Session 16

  • 1. .NET Core + ASP.NET Core Training Course Session 16
  • 2. .NET Core What we learned? Session 6 ~ 15 Overview • ASP.NET Core Basics • Middleware, Controllers, Action Filters and Routing • Models • Views • Entity Framework Core (Modeling) • Entity Framework Core (Querying Data) • Entity Framework Core (Saving Data)
  • 3. .NET Core What we’ll learn today? Session 16 Agenda • Entity Framework Core (Saving Data)
  • 4. .NET Core Announcing .NET Core 1.1 Preview 1 Entity Framework Core – v1.1 Preview 1 Improvements The .NET Core 1.1 release is the first 1.x minor update. Its primary product theme is adding support for new operating system distributions. 1380 APIs were added in this release. Operating System Distributions Support for the following distributions was added: • Linux Mint 18 • OpenSUSE 42.1 • macOS 10.12 • Windows Server 2016
  • 5. .NET Core Announcing EF Core 1.1 Preview 1 Entity Framework Core – v1.1 Preview 1 Improved LINQ translation In the 1.1 release we can see good progress improving the EF Core LINQ provider. This enables more queries to successfully execute, with more logic being evaluated in the database (rather than in memory). DbSet.Find DbSet.Find(…) is an API that is present in EF6.x and has been one of the more common requests for EF Core. It allows you to easily query for an entity based on its primary key value. If the entity is already loaded into the context, then it is returned without querying the database.
  • 6. .NET Core Announcing EF Core 1.1 Preview 1 Entity Framework Core – v1.1 Preview 1 Mapping to fields The new HasField(…) method in the fluent API allows you to configure a backing field for a property. This is most commonly done when a property does not have a setter.
  • 7. .NET Core Announcing EF Core 1.1 Preview 1 Entity Framework Core – v1.1 Preview 1 By default, EF will use the field when constructing instances of your entity during a query, or when it can’t use the property (i.e. it needs to set the value but there is no property setter). You can change this via the new UsePropertyAccessMode(…) API.
  • 8. .NET Core Announcing EF Core 1.1 Preview 1 Entity Framework Core – v1.1 Preview 1 You can also create a property in your model that does not have a corresponding property in the entity class, but uses a field to store the data in the entity. This is different from Shadow Properties, where the data is stored in the change tracker. This would typically be used if the entity class uses methods to get/set values. You can give EF the name of the field in the Property(…) API. If there is no property with the given name, then EF will look for a field.
  • 9. .NET Core Announcing EF Core 1.1 Preview 1 Entity Framework Core – v1.1 Preview 1 You can also choose to give the property a name, other than the field name. This name is then used when creating the model, most notably it will be used for the column name that is mapped to in the database.
  • 10. .NET Core Announcing EF Core 1.1 Preview 1 Entity Framework Core – v1.1 Preview 1 You can use the EF.Property(…) method to refer to these properties in a LINQ query.
  • 11. .NET Core Announcing EF Core 1.1 Preview 1 Entity Framework Core – v1.1 Preview 1 Explicit Loading Explicit loading allows you to load the contents of a navigation property for an entity that is tracked by the context.
  • 12. .NET Core Announcing EF Core 1.1 Preview 1 Entity Framework Core – v1.1 Preview 1 Additional EntityEntry APIs from EF6.x 1. Reload() 2. GetModifiedProperties() 3. GetDatabaseValues() 4. etc. These APIs are most commonly accessed by calling the DbContext.Entry(object entity) method.
  • 13. .NET Core Announcing EF Core 1.1 Preview 1 Entity Framework Core – v1.1 Preview 1 Connection resiliency Connection resiliency automatically retries failed database commands. This release includes an execution strategy that is specifically tailored to SQL Server (including SQL Azure). This execution strategy is included in our SQL Server provider. It is aware of the exception types that can be retried and has sensible defaults for maximum retries, delay between retries, etc.
  • 14. .NET Core Announcing EF Core 1.1 Preview 1 Entity Framework Core – v1.1 Preview 1 Connection resiliency Connection resiliency automatically retries failed database commands. This release includes an execution strategy that is specifically tailored to SQL Server (including SQL Azure). This execution strategy is included in our SQL Server provider. It is aware of the exception types that can be retried and has sensible defaults for maximum retries, delay between retries, etc.
  • 15. .NET Core Announcing EF Core 1.1 Preview 1 Entity Framework Core – v1.1 Preview 1 Connection resiliency Other database providers may choose to add retry strategies that are tailored to their database. There is also a mechanism to register a custom execution strategy of your own.
  • 16. .NET Core Announcing EF Core 1.1 Preview 1 Entity Framework Core – v1.1 Preview 1 SQL Server memory-optimized table support Memory-Optimized Tables are a feature of SQL Server. You can now specify that the table an entity is mapped to is memory-optimized. When using EF Core to create and maintain a database based on your model (either with migrations or Database.EnsureCreated), a memory-optimized table will be created for these entities.
  • 17. .NET Core Announcing EF Core 1.1 Preview 1 Entity Framework Core – v1.1 Preview 1 Simplified service replacement In EF Core 1.0 it is possible to replace internal services that EF uses, but this is complicated and requires you to take control of the dependency injection container that EF uses. In 1.1 we have made this much simpler, with a ReplaceService(…) method that can be used when configuring the context.
  • 18. .NET Core Announcing EF Core 1.1 Preview 1 Entity Framework Core – v1.1 Preview 1 Simplified service replacement In EF Core 1.0 it is possible to replace internal services that EF uses, but this is complicated and requires you to take control of the dependency injection container that EF uses. In 1.1 we have made this much simpler, with a ReplaceService(…) method that can be used when configuring the context.
  • 19. .NET Core EF Core vs. EF6.x Entity Framework Core vs Entity Framework 6.x Which One Is Right for You? What is EF6.x? Entity Framework 6.x (EF6.x) is a tried and tested data access technology with many years of features and stabilization. It first released in 2008, as part of .NET Framework 3.5 SP1 and Visual Studio 2008 SP1. Starting with the EF4.1 release it has shipped as the EntityFramework NuGet package - currently the most popular package on NuGet.org. EF6.x continues to be a supported product, and will continue to see bug fixes and minor improvements for some time to come.
  • 20. .NET Core EF Core vs. EF6.x Entity Framework Core vs Entity Framework 6.x Which One Is Right for You? What is EF Core? Entity Framework Core (EF Core) is a lightweight, extensible, and cross-platform version of Entity Framework. EF Core introduces many improvements and new features when compared with EF6.x. At the same time, EF Core is a new code base and very much a v1 product. EF Core keeps the developer experience from EF6.x, and most of the top-level APIs remain the same too, so EF Core will feel very familiar to folks who have used EF6.x. At the same time, EF Core is built over a completely new set of core components. This means EF Core doesn’t automatically inherit all the features from EF6.x. Some of these features will show up in future releases (such as lazy loading), other less commonly used features will not be implemented in EF Core.
  • 21. .NET Core EF Core vs. EF6.x Entity Framework Core vs Entity Framework 6.x Which One Is Right for You? What is EF Core? Entity Framework Core (EF Core) is a lightweight, extensible, and cross-platform version of Entity Framework. EF Core introduces many improvements and new features when compared with EF6.x. At the same time, EF Core is a new code base and very much a v1 product. EF Core keeps the developer experience from EF6.x, and most of the top-level APIs remain the same too, so EF Core will feel very familiar to folks who have used EF6.x. At the same time, EF Core is built over a completely new set of core components. This means EF Core doesn’t automatically inherit all the features from EF6.x. Some of these features will show up in future releases (such as lazy loading), other less commonly used features will not be implemented in EF Core. The new, extensible, and lightweight core has also allowed us to add some features to EF Core that will not be implemented in EF6.x (such as alternate keys and mixed client/database evaluation in LINQ queries).
  • 22. .NET Core EF Core vs. EF6.x Entity Framework Core vs Entity Framework 6.x Guidance for new applications Because EF Core is a new product, and still lacks some critical O/RM features, EF6.x will still be the most suitable choice for many applications. These are the types of applications we would recommend using EF Core for. • New applications that do not require features that are not yet implemented in EF Core. Review Feature Comparison to see if EF Core may be a suitable choice for your application. • Applications that target .NET Core, such as Universal Windows Platform (UWP) and ASP.NET Core applications. These applications can not use EF6.x as it requires the Full .NET Framework (i.e. .NET Framework 4.5).
  • 23. .NET Core EF Core vs. EF6.x Entity Framework Core vs Entity Framework 6.x Guidance for existing EF6.x applications Because of the fundamental changes in EF Core we do not recommend attempting to move an EF6.x application to EF Core unless you have a compelling reason to make the change. If you want to move to EF Core to make use of new features, then make sure you are aware of its limitations before you start.
  • 24. .NET Core EF Core vs. EF6.x Entity Framework Core vs Entity Framework 6.x Feature Comparison, Features not in EF Core • Creating a Model • Complex/value types are types that do not have a primary key and are used to represent a set of properties on an entity type. • Visualizing a model to see a graphical representation of the code-based model. • Simple type conversions such as string => xml. • Spatial data types such as SQL Server’s geography & geometry. • Many-to-many relationships without join entity. You can already model a many-to-many relationship with a join entity, see Relationships for details. • Alternate inheritance mapping patterns for relational databases, such as table per type (TPT) and table per concrete type (TPC). Table per hierarchy (TPH) is already supported.
  • 25. .NET Core EF Core vs. EF6.x Entity Framework Core vs Entity Framework 6.x Feature Comparison, Features not in EF Core • Querying Data • Improved translation to enable more queries to successfully execute, with more logic being evaluated in the database (rather than in-memory). • GroupBy translation in particular will move translation of the LINQ GroupBy operator to the database, rather than in-memory. • Lazy loading enables navigation properties to be automatically populated from the database when they are accessed. • Raw SQL queries for non-model types allows a raw SQL query to be used to populate types that are not part of the model (typically for denormalized view-model data).
  • 26. .NET Core EF Core vs. EF6.x Entity Framework Core vs Entity Framework 6.x Feature Comparison, Features not in EF Core • Saving Data • Simple command interception provides an easy way to read/write commands before/after they are sent to the database. • Missing EntityEntry APIs from EF6.x such as Reload, GetModifiedProperties, GetDatabaseValues etc. • Stored procedure mapping allows EF to use stored procedures to persist changes to the database (FromSql already provides good support for using a stored procedure to query, see Raw SQL Queries for details).
  • 27. .NET Core EF Core vs. EF6.x Entity Framework Core vs Entity Framework 6.x Feature Comparison, Features not in EF Core • Database Schema Management • Visual Studio wizard for reverse engineer that allows you to visually configure connection, select tables, etc. when creating a model from an existing database. • Update model from database allows a model that was previously reverse engineered from the database to be refreshed with changes made to the schema. • Seed data allows a set of data to be easily upserted to the database.
  • 28. .NET Core Porting from EF6.x to EF Core Entity Framework Core vs Entity Framework 6.x Ensure EF Core Will Work for Your Application • Missing features • Behavior changes • DbSet.Add/Attach and graph behavior In EF6.x, calling DbSet.Add() on an entity results in a recursive search for all entities referenced in its navigation properties. Any entities that are found, and are not already tracked by the context, are also be marked as added. DbSet.Attach() behaves the same, except all entities are marked as unchanged.
  • 29. .NET Core Porting from EF6.x to EF Core Entity Framework Core vs Entity Framework 6.x Ensure EF Core Will Work for Your Application • DbSet.Add/Attach and graph behavior EF Core performs a similar recursive search, but with some slightly different rules. • The root entity is always in the requested state (added for DbSet.Add and unchanged for DbSet.Attach). • For entities that are found during the recursive search of navigation properties: • If the primary key of the entity is store generated • If the primary key is not set to a value, the state is set to added. The primary key value is considered “not set” if it is assigned the CLR default value for the property type (i.e. 0 for int, null for string, etc.). • If the primary key is set to a value, the state is set to unchanged. • If the primary key is not database generated, the entity is put in the same state as the root.
  • 30. .NET Core Porting from EF6.x to EF Core Entity Framework Core vs Entity Framework 6.x Ensure EF Core Will Work for Your Application • Code First database initialization EF6.x has a significant amount of magic it performs around selecting the database connection and initializing the database. Some of these rules include: • If no configuration is performed, EF6.x will select a database on SQL Express or LocalDb. • If a connection string with the same name as the context is in the applications App/Web.config file, this connection will be used. • If the database does not exist, it is created. • If none of the tables from the model exist in the database, the schema for the current model is added to the database. If migrations are enabled, then they are used to create the database.
  • 31. .NET Core Porting from EF6.x to EF Core Entity Framework Core vs Entity Framework 6.x Ensure EF Core Will Work for Your Application • Code First table naming convention • EF6.x runs the entity class name through a pluralization service to calculate the default table name that the entity is mapped to. • EF Core uses the name of the DbSet property that the entity is exposed in on the derived context. If the entity does not have a DbSet property, then the class name is used.
  • 32. .NET Core Porting from EF6.x to EF Core Entity Framework Core vs Entity Framework 6.x Porting an EDMX-Based Model (Model First & Database First) EF Core does not support the EDMX file format for models. The best option to port these models, is to generate a new code-based model from the database for your application. Install EF Core NuGet packages: Install the Microsoft.EntityFrameworkCore.Tools NuGet package. You also need to install the design time NuGet package for the database provider you want to use. This is typically the runtime database provider package name with .Design post-fixed. For example, when targeting SQL Server, you would install Microsoft.EntityFrameworkCore.SqlServer.Design.
  • 33. .NET Core Porting from EF6.x to EF Core Entity Framework Core vs Entity Framework 6.x Porting an EDMX-Based Model (Model First & Database First) Regenerate the model You can now use the reverse engineer functionality to create a model based on your existing database. Run the following command in Package Manager Console (Tools –> NuGet Package Manager –> Package Manager Console). See Package Manager Console (Visual Studio) for command options to scaffold a subset of tables etc. Scaffold-DbContext "<connection string>" <database provider name>
  • 34. .NET Core Porting from EF6.x to EF Core Entity Framework Core vs Entity Framework 6.x Porting an EDMX-Based Model (Model First & Database First) Regenerate the model You can now use the reverse engineer functionality to create a model based on your existing database. Run the following command in Package Manager Console (Tools –> NuGet Package Manager –> Package Manager Console). See Package Manager Console (Visual Studio) for command options to scaffold a subset of tables etc. Scaffold-DbContext "<connection string>" <database provider name> Scaffold-DbContext "Server=(localdb)mssqllocaldb;Database=Blogging;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer
  • 35. .NET Core Porting from EF6.x to EF Core Entity Framework Core vs Entity Framework 6.x Porting a Code-Based Model (Code First & Code First to Existing Database) Install EF Core NuGet packages To use EF Core, you install the NuGet package for the database provider you want to use. For example, when targeting SQL Server, you would install Microsoft.EntityFrameworkCore.SqlServer. If you are planning to use migrations, then you should also install the Microsoft.EntityFrameworkCore.Tools package. It is fine to leave the EF6.x NuGet package (EntityFramework) installed, as EF Core and EF6.x can be used side-by-side in the same application. However, if you aren’t intending to use EF6.x in any areas of your application, then uninstalling the package will help give compile errors on pieces of code that need attention.
  • 36. .NET Core Porting from EF6.x to EF Core Entity Framework Core vs Entity Framework 6.x Porting a Code-Based Model (Code First & Code First to Existing Database) Swap namespaces Most APIs that you use in EF6.x are in the System.Data.Entity namespace (and related sub- namespaces). The first code change is to swap to the Microsoft.EntityFrameworkCore namespace. You would typically start with your derived context code file and then work out from there, addressing compilation errors as they occur. Context configuration (connection etc.) EF Core has less magic around detecting the database to connect to. You will need to override the OnConfiguring method on your derived context, and use the database provider specific API to setup the connection to the database.
  • 37. .NET Core Porting from EF6.x to EF Core Entity Framework Core vs Entity Framework 6.x Porting a Code-Based Model (Code First & Code First to Existing Database) Context configuration (connection etc.) Most EF6.x applications store the connection string in the applications App/Web.config file. In EF Core, you read this connection string using the ConfigurationManager API. You may need to add a reference to the System.Configuration framework assembly to be able to use this API.
  • 38. .NET Core Porting from EF6.x to EF Core Entity Framework Core vs Entity Framework 6.x Porting a Code-Based Model (Code First & Code First to Existing Database) Existing migrations There isn’t really a feasible way to port existing EF6.x migrations to EF Core. If possible, it is best to assume that all previous migrations from EF6.x have been applied to the database and then start migrating the schema from that point using EF Core. To do this, you would use the Add-Migration command to add a migration once the model is ported to EF Core. You would then remove all code from the Up and Down methods of the scaffolded migration. Subsequent migrations will compare to the model when that initial migration was scaffolded.
  • 39. .NET Core Miscellaneous, Connection Strings Entity Framework Core Miscellaneous Topics Most database providers require some form of connection string to connect to the database. Sometimes this connection string contains sensitive information that needs to be protected. You may also need to change the connection string as you move your application between environments, such as development, testing, and production.
  • 40. .NET Core Miscellaneous, Connection Strings Entity Framework Core Miscellaneous Topics Full .NET Applications Full .NET applications, such as WinForms, WPF, Console, and ASP.NET 4, have a tried and tested connection string pattern. The connection string should be added to your applications App.config file (Web.config if you are using ASP.NET). If your connection string contains sensitive information, such as username and password, you can protect the contents of the configuration file using Protected Configuration.
  • 41. .NET Core Miscellaneous, Connection Strings Entity Framework Core Miscellaneous Topics Full .NET Applications You can then read the connection string using the ConfigurationManager API in your context’s OnConfiguring method. You may need to add a reference to the System.Configuration framework assembly to be able to use this API.
  • 42. .NET Core Miscellaneous, Connection Strings Entity Framework Core Miscellaneous Topics ASP.NET Core In ASP.NET Core the configuration system is very flexible, and the connection string could be stored in appsettings.json, an environment variable, the user secret store, or another configuration source. See the Configuration section of the ASP.NET Core documentation for more details. The following example shows the connection string stored in appsettings.json.
  • 43. .NET Core Miscellaneous, Connection Strings Entity Framework Core Miscellaneous Topics ASP.NET Core The context is typically configured in Startup.cs with the connection string being read from configuration. Note the GetConnectionString() method simply looks for a configuration value whose key is ConnectionStrings:<connection string name>.
  • 44. .NET Core Miscellaneous, Logging Entity Framework Core Miscellaneous Topics Create a logger The first step is to create an implementation of ILoggerProvider and ILogger. ILoggerProvider is the component that decides when to create instances of your logger(s). The provider may choose to create different loggers in different situations. ILogger is the component that does the actual logging. It will be passed information from the framework when certain events occur.
  • 45. .NET Core Miscellaneous, Logger Entity Framework Core Miscellaneous Topics Register logger, ASP.NET Core In an ASP.NET Core application, you register your logger in the Configure method of Startup.cs:
  • 46. .NET Core Miscellaneous, Logger Entity Framework Core Miscellaneous Topics Register logger, Other applications In your application startup code, create and instance of you context and register your logger. You only need to register the logger with a single context instance. Once you have registered it, it will be used for all other instances of the context in the same AppDomain.
  • 47. .NET Core Miscellaneous, Logger Entity Framework Core Miscellaneous Topics Filtering what is logged The easiest way to filter what is logged, is to adjust your logger provider to only return your logger for certain categories of events. For EF, the category passed to your logger provider will be the type name of the component that is logging the event. For example, here is a logger provider that returns the logger only for events related to executing SQL against a relational database. For all other categories of events, a null logger (which does nothing) is returned.
  • 48. .NET Core Miscellaneous, Using DbContext with dependency injection Entity Framework Core Miscellaneous Topics EF supports using DbContext with a dependency injection container. Your DbContext type can be added to the service container by using AddDbContext<TContext>. AddDbContext will add make both your DbContext type, TContext, and DbContextOptions<TContext> to the available for injection from the service container.
  • 49. .NET Core Miscellaneous, Using DbContext with dependency injection Entity Framework Core Miscellaneous Topics EF supports using DbContext with a dependency injection container. Your DbContext type can be added to the service container by using AddDbContext<TContext>. AddDbContext will add make both your DbContext type, TContext, and DbContextOptions<TContext> to the available for injection from the service container.
  • 50. .NET Core Miscellaneous, Using DbContext with dependency injection Entity Framework Core Miscellaneous Topics
  • 51. .NET Core Miscellaneous, Using DbContext with dependency injection Entity Framework Core Miscellaneous Topics Using IDbContextFactory<TContext> As an alternative to the options above, you may also provide an implementation of IDbContextFactory<TContext>. EF command line tools and dependency injection can use this factory to create an instance of your DbContext. This may be required in order to enable specific design-time experiences such as migrations. Implement this interface to enable design-time services for context types that do not have a public default constructor. Design-time services will automatically discover implementations of this interface that are in the same assembly as the derived context.
  • 52. .NET Core Miscellaneous, Using DbContext with dependency injection Entity Framework Core Miscellaneous Topics
  • 53. .NET Core Understanding EF Services Entity Framework Core Miscellaneous Topics Entity Framework executes as a collection of services working together. A service is a reusable component. A service is typically an implementation of an interface. Services are available to other services via dependency injection (DI), which is implemented in EF using Microsoft.Extensions.DependencyInjection.
  • 54. .NET Core Understanding EF Services, Terms Entity Framework Core Miscellaneous Topics • Service A reusable component. In .NET, a service can be identified by a class or interface. By convention, Entity Framework only uses interfaces to identify services. • Service lifetime A description of the way in which a service is persisted and disposed across multiple uses of the same service type. • Service provider The mechanism for storing a collection of services. Also known as a service container. • Service collection The mechanism for constructing a service provider.