搜尋此網誌

顯示具有 Entity Framework 標籤的文章。 顯示所有文章
顯示具有 Entity Framework 標籤的文章。 顯示所有文章

2016-08-04

TransactionScope

0 意見
EF6新增Database.BeginTransaction()
Working with Transactions (EF6 Onwards)
Entity Framework (EF) TransactionScope vs Database.BeginTransaction
Transaction Support in Entity Framework 6
What's the point of an explicit database transaction in Entity Framework 6?




使用前必需詳閱說明:
使用交易範圍實作隱含交易
根據預設,交易會在隔離等級設為 Serializable 時執行。在讀取頻繁的系統上,常常會選取使用 Serializable 以外的隔離等級。

11.TRANSACTION ISOLATION LEVEL *****
All About TransactionScope *****
What is default IsolationLevel for TransactionScope?
.NET TransactionScope and its default Transaction Isolation level issue

Transactions and Connections in Entity Framework 4.0 *****

using new TransactionScope() Considered Harmful *****

Why is System.Transactions TransactionScope default Isolationlevel Serializable

Deadlocks w/Entity Framework - how to rerun the transaction?
Quote from Ladislav Mrnka:
Default isolation level for TransactionScope is serializable which is the most restrictive level for transaction (= causes deadlock more often). You should start by using Read committed isolation level (but you must ensure that same data are not read multiple times from the database during a transaction) to reduce database locking but it will most probably doesn't solve the problem (it can reduce the frequency)


目前用法:
using (var ts = new TransactionScope(TransactionScopeOption.Required, 
     new TransactionOptions { IsolationLevel = IsolationLevel.ReadCommitted }))
{
     //TODO
     ts.Complete();
}




TimeOut 預設1分鐘,最大10分鐘。
All About TransactionScope *****
using new TransactionScope() Considered Harmful ***
Changing TransactionScope - Timeout at runtime
Transaction scope timeout on 10 minutes
Transactionscope timeout max is only 10 mins




Introducing System.Transactions in the .NET Framework 2.0

確保交易的新利器(TransactionScope)初體驗
KB-.NET 2.0 分散式交易新利器---TransactionScope
TransactionScope與COMMIT TRAN

.NET分散式交易程式開發FAQ
多重TransactionScope與TransactionScopeOption


Nesting Transactions with a Single SQL Server Database

[IIS] 啟用Microsoft 分散式交易協調器(MSDTC)服務




ORA-02089: COMMIT is not allowed in a subordinate session

與目前連接關聯的交易已完成,但尚未處置。必須先處置交易,才能使用連接來執行 SQL 陳述式。
The transaction associated with the current connection has completed but has not been disposed. The transaction must be disposed before the connection can be used to execute SQL statements.
設定timeout

2015-05-27

Entity Framework 6

0 意見
Code First Migrate
Config File Settings
Working with Transactions (EF6 Onwards)
Transaction support

Managing DbContext the right way with Entity Framework 6: an in-depth guide *****

Discard Changes Without Disposing DbContext/ObjectContext in Entity Framework 6

Code First Annotations

DbFunctions

EF 6 Tutorials




LINQKit

PagedList
PagedList.EntityFramework




What's New in Entity Framework 6 (Plus How To Upgrade!)
打造現代網站應用: (5) Entity Framework

Getting Started with EntityFramework6 CodeFirst using MVC5

Upgrading to EF6
Entity Framework Providers for EF6
Connection Management


Announcing the release of Dynamic Data provider and EntityDataSource control for Entity Framework 6

Tutorial series updated for Entity Framework 6 Code First with MVC 5
Tutorial Series for Entity Framework 6 MVC 5 Published
Code First Goodies in Entity Framework 6
Understanding Entity Framework Code First Migrations
EF6 Code First Migrations for Multiple Models

Implementing Connection Resiliency with Entity Framework 6

Async Processing in EF6 and the Microsoft .NET Framework 4.5
Making Complex Types Useful with Entity Framework 6 Custom Configurations

Calling Stored Procedures from Entity Framework
Entity Framework 6: Update an Entity with a Many-to-Many Relation

EntityFramework 6 CodeFirst與預存程序
Entity Framework 6 的自動重試功能

Implementing a Data Access Layer with Entity Framework 6.1






EF 6.1 Alpha 1 Available
EF6.1.0 RTM Available
Entity Framework 6.1 RTM发布
EF Gets Public Mapping API, Ability To Handle Commit Failures

Entity Framework 6.1.2 Tools for Visual Studio 2012 & 2013

Code First to an Existing Database***
Entity Framework 6.1.0 Tools for Visual Studio

Creating Unit Test for Projects Using Microsoft’s Entity Framework
Test-Driven Development with Entity Framework 6


[C#.NET][Entity Framework] Custom SQL Command at EF6.1.3

Entity Framework Test

0 意見
Testing with a mocking framework (EF6 onwards)
Mocking DbSet Queries in EF6
Entity Framework 6 Mocking and Unit Testing
How EF6 Enables Mocking DbSets more easily ***

Creating Unit Test for Projects Using Microsoft’s Entity Framework
Test-Driven Development with Entity Framework 6

Mocking Entity Framework when Unit Testing ASP.NET Web API 2

Code First Entity Framework Unit Test Examples
Testing With a Fake DbContext

Unit Testing OData Web API/Entity Framework Applications

How to mock the DataContext (LINQ)
How to mock the DataContext (Entity Framework)



EF6.1 DB first edmx 產生出來的為 DbSet,文章內是用 code first 為 IDbSet,rhino mocks可能不適用
Mocking Entity Framework 6 Context with Rhino Mocks (Code First)
Entity framework 6 mocking include method on dbset
EF6 Mocking derived DbSets
Moqing Enity Framework 6 .Include() using DbSet

改用moq解決
Mocking DbSet Queries in EF6

[Visual Studio 2013][Entity Framework] 在 Unit Test 使用 Code Fist for SqlLocalDb
[C#.NET][Entity Framework] 單元測試 - 使用 NSubstitute 測試 EF6




GenericRepository
Generic Repository Pattern - Entity Framework, ASP.NET MVC and Unit Testing Triangle




Sample:
PLINQO.EntityFramework.DbContext
includeTests




Effort Entity Framework Unit Testing Tool ***
Using Effort - Entity Framework Unit Testing Tool
Unit testing in C# using xUnit, Entity Framework, Effort and ASP.NET Boilerplate.
Two strategies for testing Entity Framework - Effort and SQL CE
Effort - Entity Framework Unit Testing Tool
Using different dataloaders in Effort
Extra Effort

使用Effort CSV Export Tool輸出測試用的CSV檔
DataLoader從CSV讀入資料時,若有Nullable的欄位,需把NULL輸出為empty,不然可能會出現轉型錯誤。

2015-05-15

Repository

0 意見
設計基礎結構持續性層
在這裡要特別再次強調的是,您應該只會針對每個彙總根定義一個存放庫,如圖 7-17 所示。 若要達到在彙總內所有物件之間維持交易一致性的彙總根目標,請絕對不要針對資料庫中的每個資料表建立儲存機制。

The Repository Pattern
Implementing the Repository and Unit of Work Patterns in an ASP.NET MVC Application (9 of 10)
Repositories On Top UnitOfWork Are Not a Good Idea 針對上面那篇教學的改進
Survey of Entity Framework Unit of Work Patterns *****

Repository Pattern with C# and Entity Framework, Done Right | Mosh
4 Common Mistakes with the Repository Pattern

Unit of Work
Repositories
EntityFramework Integration
Application Services

Managing DbContext the right way with Entity Framework 6: an in-depth guide *****

EF Code First Generic Repository *****

Correct use of Repository and Unit Of Work patterns in ASP.NET MVC

Dapper Repository Tutorial ***

Repository pattern, done right *****
ADO.NET, the right way
Unit of work sample implementation for ADO.NET ***
Griffin Framework
Griffin.Core Data
Griffin DAL Generator
Sample repository using Griffin.Framework
Introducing the data mapper in Griffin.Framework

Generic implementation of Repository pattern in C# .NET *****


[Architecture Pattern] Repository
[Architecture Pattern] Repository實作查詢功能

3-4 Repository Pattern
3-5 Unit of Work Pattern

Using Repository and Unit of Work patterns with Entity Framework 4.0
Agile Entity Framework 4 Repository

Unit of Work Design Pattern
Understanding Repository and Unit of Work Pattern and Implementing Generic Repository in ASP.NET MVC using Entity Framework
Generic Repository and UnitofWork patterns in MVC
Learning MVC Part 6: Generic Repository Pattern in MVC3 Application with Entity Framework ***
Repository with Unit of Work, IoC and Unit Test
Generic Repository Framework (Generic Unit of Work)
Unit Of Work & Generic Repository with Entity Framework 5

Unit of Work with Repository Pattern MVC 5 & EF 6

What's new in ASP.net 4.5 WebForms - P 11 - Implementing the Repository Pattern
What's new in ASP.net 4.5 WebForms - P12 - Implementing CRUD with the Repository Pattern

Repository Pattern For .Net (EF, XML)

Generic Repository and Unit of Work Pattern, Entity Framework, Unit Testing, Autofac IoC Container and ASP.NET MVC

Generic Unit of Work & (Extensible) Repositories Framework *****
URF.NET
Generically Implementing the Unit of Work & Repository Pattern with Entity Framework in MVC & Simplifying Entity Graphs
Unit of Work & Repository Framework with ASP.NET MVC 5, Entity Framework 6 & Unity 3 (Quick-Start Video)



Entity Framework 5.0 Generic Repository classes for CRUD operation with complex LINQ expression. Microsoft Visual Studio Test Tools Unit Testing

West Wind Data Light Weight Business Object Library for Entity Framework Code First




Repository,我可能不會用你
To Repository Or NOT
Say No to the Repository Pattern in your DAL
MVC Solution

RESTful Day #1: Enterprise Level Application Architecture with Web APIs using Entity Framework, Generic Repository Pattern and Unit of Work

2014-10-23

Entity Framework

0 意見
MSDN
ASP.NET Data Access - Recommended Resources
ADO.NET Entity Framework
Entity Data Model 工具
Entity Framework (EF) Documentation
EF Power Tools

Code First Migrate
Config File Settings

[料理佳餚] 使用 Entity Framework Code First 應該要知道的 TPH、TPT、TPC

ObjectContext
EntityFunctions

Entities.Configuration.AutoDetectChangesEnabled = true;
Entities.Configuration.ValidateOnSaveEnabled = true;




Data Access Hands-on Labs

Entity Framework Tutorial

Entity Framework Tutorial for Beginners
Entity Framework快速入门--索引贴
Entity Framework 快速上手 & 學習資源整理
ADO.Net Entity Framework
SQL Server 2008 Entity Data Model 和 Linq to Entities
米米貓學開發

ADO.NET Entity Framework 概觀
首次接觸 ADO.NET Entity Framework
讀寫 ADO.NET Entity Framework
由 LINQ 存取 ADO.NET 物件
整合 ADO.NET Entity Framework 到應用程式中

[C#] 取得欄位的資料標記 Data Annotation from Metadata Class

Entity Framework Sample Provider
Custom ORM - Map your entity with DataSet/DataTable/DataReader

ADO.Net Entity Framework - Entity Data Model
ADO.Net Entity Framework - 簡易資料查詢





Tips for Updating and Refactoring Your Entity Framework Code
Tips for Updating and Refactoring Your Entity Framework Code, Part 2

Building the Business Logic Layer classes with Entity Framework and Code First
Various strategies to initialize Database in Entity Framework

EF Designer Code Generation Templates
Entity Framework Repository & Unit of Work T4 Template
Using T4 templates in Entity framework





Writing SQL queries for entities
Entity Framework Automatic Detect Changes

DbSetMigrationsExtensions.AddOrUpdate
How to seed data with AddOrUpdate with a complex key in EF 4.3

Add/Attach and Entity States
MERGE-like function in Entity Framework
Update Row if it Exists Else Insert Logic with Entity Framework

Entity Framework and slow bulk INSERTs
Prefixing ID columns with the table name in Entity Framework
Executing Raw SQL Queries using Entity Framework
Working with Stored Procedures in Entity Framework - Part 1
Calling Stored Procedures from Entity Framework

Entity Framework projections to Immutable Types (IEnumerable vs IQueryable)

Implementing a WCF Service with Entity Framework (v4.5)

Performing Asynchronous Operations Using Entity Framework

Domain modeling with Entity Framework scorecard

Entity Validation and the Entity Framework – Part 1
Entity Validation and the Entity Framework – Part 2
Update: Entity Framework Generic Data Access

Social Club: Sample application using WinForms, C#.NET, ADO.NET and MS Access
SocialClub: A Sample application using C#.NET, Entity Framework 5 and LocalDb

Using the Repository Pattern with ASP.NET MVC and Entity Framework




Code first migration commands for Entity Framework
EF Code First Migrations Deployment to an Azure Cloud Service

Event Calendar with Entity Framework: Quick Guide and Sample

Seeding Entity Framework Database from CSV

Missing EF Feature Workarounds: Cascade delete orphans
Missing EF Feature Workarounds: Encapsulated collections

Avoid many-to-many mappings in ORMs

Catching Bad Data in Entity Framework




Entity Framework Refresh context?
[C#.NET][Entity Framework] 快取查詢與 DbEntityEntry.Reload
[C#.NET][Entity Framework] 幾個提升 EF 效能的方法

Entity Framework Performance and What You Can Do About It
91 FB 解說



EntityFramework.BulkInsert
EntityFramework.Extended

2014-08-28

Unable to load the specified metadata resource

0 意見
無法載入指定的中繼資料資源
Unable to load the specified metadata resource
修改Metadata的namespace
var builder = new EntityConnectionStringBuilder
{
 Provider = "System.Data.SqlClient",
 ProviderConnectionString = connectionString,
 Metadata = @"res://*/Data.MyModel.csdl|res://*/Data.MyModel.ssdl|res://*/Data.MyModel.msl"
};

System.Data.MetadataException: Unable to load the specified metadata resource
Entity Framework MetadataException: Unable to load the specified metadata resource
關於 Entity Framework 獨立放在 DAL 專案的注意事項

2014-08-16

AutoMapper

0 意見
Getting Started Guide
AutoMapperSamples

MRKT AutoMapper

Can Automapper be used in a console application?

Using AutoMapper: Getting Started
Using AutoMapper: Creating Mappings
Using AutoMapper: Mapping Instances

Conditional mapping
Custom value resolvers
Null substitution

Translating Objects of One Type to Another with AutoMapper ***** 整理的很詳細
Automapper: Mapping objects

Conditionally overwrite destination if no destination object is used
AutoMapper settings properties to null on destination object

AutoMapper 兩個物件對映到一個類別
Automapper convert from multiple sources
automapper multi objects to one object
How to configure automapper to map from two source objects to a destination object?
(若用在List上可能沒效)

使用AutoMapper做物件複製,注意仍需要做CreateMap,不然會取到Source物件的參考。
Copy object to object (with Automapper ?)

Mapper.Map()是全域的,若要動態建立規則,要使用ConfigurationStore
Different mapping rules for same entity types in AutoMapper
Using the instance version of CreateMap and Map with a WCF service?

opt.UseValue(value)是靜態方法,會使用相同的值。
AutoMapper Tip: DateTime and UseValue don’t mix
AutoMapper: UseValue vs ResolveUsing vs MapFrom
AutoMapper使用简单总结

AutoMapper: “Ignore the rest”?

AutoMapper registration in Unity DI




automapper update existing entity
Updating Entities from DTOs with AutoMapper
How to update an existing Entity from ViewModel using Automapper and EF4 DbContext with Lazy Loading enabled
Using Automapper to update an existing Entity POCO
Why mapping DTOs to Entities using AutoMapper and EntityFramework is horrible




Using AutoMapper to prevent SELECT N+1 problems
Using AutoMapper to perform LINQ aggregations
Projecting computed properties with LINQ and AutoMapper


Using AutoMapper to copy Metadata from Entities to ViewModels

CRUD Opearations using AutoMapper in an MVC Application




AutoMapper 3加入了对开放式泛型以及回调的支持
AutoMapper以及创建跨平台的程序集