Quantcast
Channel: Entity Framework
Viewing all 10318 articles
Browse latest View live

Edited Unassigned: Eager loading silently fails when selecting an anonymous type [2939]

$
0
0
```c#
var results = dbContext.Entities
.Include(entity => entity.ChildCollection)
.Select(entity => new { Entity = entity, Calculation = Entity.NavProperty.OtherInfo * 2 })
.ToListAsync();
```

You would expect some items in `results` to have `.Entity.ChildCollection` filled, but instead `.Entity.ChildCollection` is empty and no warning is given.



Edited Issue: .NET/EF6 ObjectContext leak using compiled LINQ query that references String.StartsWith() [2937]

$
0
0
Repro:

class Program
{
static void Main(string[] args)
{
var test = new Test();
test.Run();

GC.WaitForPendingFinalizers();
GC.Collect();

Console.WriteLine("set breakpoint here -> Diagnostic Tools -> Take Snapshot -> View Heap -> context still rooted");
Console.ReadKey();
}
}

public class Test
{
public void Run()
{
using (var context = new Model1Container())
{
var sec1 = new Security { SysRowID = Guid.NewGuid(), Company = "Contoso", SecCode = "Foo" };
var sec2 = new Security { SysRowID = Guid.NewGuid(), Company = "Contoso", SecCode = "Bar" };
var sec3 = new Security { SysRowID = Guid.NewGuid(), Company = "Microsoft", SecCode = "Foo" };

context.AddToSecurities(sec1);
context.AddToSecurities(sec2);
context.AddToSecurities(sec3);

context.SaveChanges();
}

using (var context = new Model1Container())
{
Expression<Func<Model1Container, string, string, IEnumerable<Security>>> expression =
(ctx, company, token) =>
(from row in ctx.Securities
where row.Company == company && row.SecCode.StartsWith(token)
select row);

var query = CompiledQuery.Compile(expression);
var result = query(context, "Contoso", "Foo").ToList();
}
}
}



Model:


public partial class Model1Container : ObjectContext
{
public Model1Container() : base("name=Model1Container", "Model1Container")
{
this.ContextOptions.LazyLoadingEnabled = true;
OnContextCreated();
}

partial void OnContextCreated();

public ObjectSet<Security> Securities
{
get
{
if ((_Securities == null))
{
_Securities = base.CreateObjectSet<Security>("Securities");
}
return _Securities;
}
}
private ObjectSet<Security> _Securities;

public void AddToSecurities(Security security)
{
base.AddObject("Securities", security);
}
}

[EdmEntityTypeAttribute(NamespaceName="Model1", Name="Security")]
[Serializable()]
[DataContractAttribute(IsReference=true)]
public partial class Security : EntityObject
{
public static Security CreateSecurity(global::System.Guid sysRowID, global::System.String company, global::System.String secCode)
{
Security security = new Security();
security.SysRowID = sysRowID;
security.Company = company;
security.SecCode = secCode;
return security;
}

[EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)]
[DataMemberAttribute()]
public global::System.Guid SysRowID
{
get
{
return _SysRowID;
}
set
{
if (_SysRowID != value)
{
OnSysRowIDChanging(value);
ReportPropertyChanging("SysRowID");
_SysRowID = StructuralObject.SetValidValue(value);
ReportPropertyChanged("SysRowID");
OnSysRowIDChanged();
}
}
}
private global::System.Guid _SysRowID;
partial void OnSysRowIDChanging(global::System.Guid value);
partial void OnSysRowIDChanged();

[EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
[DataMemberAttribute()]
public global::System.String Company
{
get
{
return _Company;
}
set
{
OnCompanyChanging(value);
ReportPropertyChanging("Company");
_Company = StructuralObject.SetValidValue(value, false);
ReportPropertyChanged("Company");
OnCompanyChanged();
}
}
private global::System.String _Company;
partial void OnCompanyChanging(global::System.String value);
partial void OnCompanyChanged();

[EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
[DataMemberAttribute()]
public global::System.String SecCode
{
get
{
return _SecCode;
}
set
{
OnSecCodeChanging(value);
ReportPropertyChanging("SecCode");
_SecCode = StructuralObject.SetValidValue(value, false);
ReportPropertyChanged("SecCode");
OnSecCodeChanged();
}
}
private global::System.String _SecCode;
partial void OnSecCodeChanging(global::System.String value);
partial void OnSecCodeChanged();
}





Edited Issue: SqlFunctions.CharIndex Incorrect Parameter Order [2935]

$
0
0
Seen in Version 6.1.3

The parameters for SqlFunction.CharIndex are documented as:

```
// Summary:
// Returns the starting position of one expression
// found within another expression.
//
// Parameters:
// toSearch:
// The string expression to be searched.
//
// target:
// The string expression to be found.
//
// Returns:
// The starting position of target if it is found in toSearch .
//
public static int? CharIndex(string toSearch, string target);
```
However, given the results below, it appears the parameters need to be swapped around in order to achieve the desired functionality.

```
// Called as documented, string to search "ABCDEFG", string to be found "D"
DbContext.Items.Select(o => SqlFunctions.CharIndex("ABCDEFG", "D"));

//Expected Result: 4
//Actual Result: 0

// Called with parameters swapped
DbContext.Items.Select(o => SqlFunctions.CharIndex("D", "ABCDEFG"));

//Result: 4

```
This is also the case for the other 5 overloaded methods.


Edited Issue: SqlFunctions.CharIndex Incorrect Parameter Order [2935]

$
0
0
Seen in Version 6.1.3

The parameters for SqlFunction.CharIndex are documented as:

```
// Summary:
// Returns the starting position of one expression
// found within another expression.
//
// Parameters:
// toSearch:
// The string expression to be searched.
//
// target:
// The string expression to be found.
//
// Returns:
// The starting position of target if it is found in toSearch .
//
public static int? CharIndex(string toSearch, string target);
```
However, given the results below, it appears the parameters need to be swapped around in order to achieve the desired functionality.

```
// Called as documented, string to search "ABCDEFG", string to be found "D"
DbContext.Items.Select(o => SqlFunctions.CharIndex("ABCDEFG", "D"));

//Expected Result: 4
//Actual Result: 0

// Called with parameters swapped
DbContext.Items.Select(o => SqlFunctions.CharIndex("D", "ABCDEFG"));

//Result: 4

```
This is also the case for the other 5 overloaded methods.


Commented Unassigned: Eager loading silently fails when selecting an anonymous type [2939]

$
0
0
```c#
var results = dbContext.Entities
.Include(entity => entity.ChildCollection)
.Select(entity => new { Entity = entity, Calculation = Entity.NavProperty.OtherInfo * 2 })
.ToListAsync();
```

You would expect some items in `results` to have `.Entity.ChildCollection` filled, but instead `.Entity.ChildCollection` is empty and no warning is given.


Comments: I see. Can I convert this into a feature request? There is not a good way to do what I need to do otherwise, which is to load a list of entities with multiple child collections on each entity, plus an arbitrary calculation associated to each entity. Without breaking existing users, the Include *could* flow through to the Entity property since its shape is not changing. Or this would be an even better alternative: ```c# var results = dbContext.Entities .Select(entity => new { Entity = entity, Calculation = Entity.NavProperty.OtherInfo * 2 }) .Include(info => info.Entity.ChildCollection) .ToListAsync(); ```

Updated Wiki: Roadmap

Updated Wiki: specs

$
0
0

Project Moved to GitHub

This project is now maintained at https://github.com/aspnet/EntityFramework6.

Past Feature Specification

The following specs are for features delivered from this CodePlex project.

EF 6.1

These are the specs created for the EF6.1 release. Some smaller features/changes do not have specs, visit theEF Version History page for a complete list of features/changes.

EF 6

These are the specs created for the EF6 release. Some smaller features/changes do not have specs, visit theEF Version History page for a complete list of features/changes.

EF 5

The EF5 release was largely completed prior to moving to CodePlex, these specs only include the final set of changes made in EF5. Visit theEF Version History page for a complete list of features/changes.

Backlog

These documents are for features that have not yet been assigned a release.

Updated Wiki: specs

$
0
0

Project Moved to GitHub

This project is now maintained at https://github.com/aspnet/EntityFramework6.

Past Feature Specification

The following specs are for features delivered from this CodePlex project.

EF 6.1

These are the specs created for the EF6.1 release. Some smaller features/changes do not have specs, visit theEF Version History page for a complete list of features/changes.

EF 6

These are the specs created for the EF6 release. Some smaller features/changes do not have specs, visit theEF Version History page for a complete list of features/changes.

EF 5

The EF5 release was largely completed prior to moving to CodePlex, these specs only include the final set of changes made in EF5. Visit theEF Version History page for a complete list of features/changes.

Backlog

These documents are for features that have not yet been assigned a release.


Updated Wiki: specs

$
0
0

Project Moved to GitHub

This project is now maintained at https://github.com/aspnet/EntityFramework6.

Past Feature Specifications

The following specs are for features delivered from this CodePlex project.

EF 6.1

These are the specs created for the EF6.1 release. Some smaller features/changes do not have specs, visit theEF Version History page for a complete list of features/changes.

EF 6

These are the specs created for the EF6 release. Some smaller features/changes do not have specs, visit theEF Version History page for a complete list of features/changes.

EF 5

The EF5 release was largely completed prior to moving to CodePlex, these specs only include the final set of changes made in EF5. Visit theEF Version History page for a complete list of features/changes.

Backlog

These documents are for features that have not yet been assigned a release.

Updated Wiki: Design Meeting Notes

$
0
0

Project Moved to GitHub

This project is now maintained at https://github.com/aspnet/EntityFramework6.

Past Design Meeting Notes

The following notes are from design meetings before we moved to GitHub.

The Entity Framework team has a weekly design meeting in which we discuss/recap design and other issues with the codebase. These are the notes from those meetings. The intention is to provide a history of what decisions have been made and why. No attempt is made to go back and update notes from older meetings if we later change a decision and decide to do something different.

Note: Design meeting notes for EF Core can be found on GitHub.

January 23, 2014

  • Reverse engineer database to Code First model

January 16, 2014

  • EF 6.1.0 API Review

January 9, 2014

  • Scaffolded empty DbContext for Code First

December 5, 2013

  • New Database.Log content
  • Designer “White Tests”
  • Index attribute

October 17, 2013

  • Code First in the new EDM wizard
  • Open-sourcing the EF Tools
  • Adding new interception interfaces
  • Plan for transaction commit failure workaround

October 3, 2013

  • Entity Framework 6.0.1 performance status

July 26, 2013

  • API Review: Interception
  • API Review: Code First Stored Procedure Mapping

July 18, 2013

  • General API review and cleanup

July 10, 2013

  • API Review: Code Based Config & Dependency Resolution

July 5, 2013

  • Handling connection failures on transaction commit

June 6, 2013

  • HasPrecision in lightweight conventions
  • Make command tree interception internal for EF6?

May 16, 2013

  • Time format in DbCommandLogger
  • Potential breaking change to IDbSet
  • Conversion to lightweight conventions

May 9, 2013

  • Interception building blocks
  • DbContext.Database.Log

April 11, 2013

  • Default providers
    • The default connection factory
    • Default provider configuration
    • Additional config file elements
    • DbProviderServices methods
  • Model-based conventions exploratory testing

April 4, 2013

  • Revisit: Using ExecuteSqlCommand without a transaction
  • Revisit: Extension method class naming
  • New transient error codes

April 2, 2013

  • API Review: Multiple Contexts per Database
  • API Review: Configurable Migrations History Table

March 28, 2013

  • Rename of DbExtensions to IQueryableExtensions
  • Pattern for customizing migrations history table
  • Turning off automatic transaction creation
  • Buffering in EntityClient

March 21, 2013

  • Missing property handling in lightweight conventions
  • Code First stored procedure mapping

March 19, 2013

  • Connection Resiliency Review

March 18, 2013

  • Async Query & Save API Review

March 14, 2013

  • File/code-based configuration precedence

March 13, 2013

  • Custom Code First Conventions

March 7, 2013

  • Custom migration operations usability
  • WrapService naming
  • Database initializers and shared databases

February 28, 2013

  • Models with nested types in Code First
  • Configuration of connection resiliency execution strategy
  • Behavior of disposed DbContextTransaction

February 20, 2013

  • Mapping to fields
  • Removal of unused resources

February 14, 2013

  • Branching for EF releases
  • Pull request: extending Migrations
  • Code First: modification function mapping API (mapping to stored procs)

February 7, 2013

  • DbContext and transactions (continued)
  • Pull request: extending Migrations
  • Issues with SQL Server spatial types

January 31, 2013

  • DbContext and transactions
  • Code First: modification function mapping (mapping to stored procs)

January 24, 2013

  • Buffering data reader perf
  • Provider-agnostic testing
  • Porting old SQL tests

January 17, 2013

  • Metadata API surface
  • Pluralization service exploratory testing feedback
  • Metadata unification
  • Porting existing SQL tests
  • How should pluralizers be made available?

January 10, 2013

  • Clustered/non-clustered unique identifier primary keys and SQL Azure

December 13, 2012

  • Lightweight conventions
  • Clustered/non-clustered unique identifier primary keys
  • Potential contribution for pluralization service

December 6, 2012

  • Additional ObjectContext and EntityConnection constructors
  • Default schema changes during initialization
  • Making EF queries buffer by default
  • SQL Azure connection resiliency
  • WET, DAMP, or DRY tests

November 29, 2012

  • Handling pull requests
  • Making READ_COMMITTED_SNAPSHOT the default
  • Database First WinForms data binding

November 20, 2012

  • Automatic EntityTypeConfiguration discovery

November 15, 2012

  • Lightweight conventions
  • View generation API
  • Removal of Code Contracts

November 8, 2012

  • Lightweight conventions
  • Connection resiliency to transient failures

October 25, 2012

  • Change default mapping for DateTime
  • Lightweight conventions
  • DbConfiguration exploratory testing
  • Code Contracts discussion

October 11, 2012

  • Lightweight conventions

October 4, 2012

  • Global spatial provider
  • Set-based configuration

September 27, 2012

  • Dependency resolver scoping
  • Sugar methods for services
  • Simplified API for common conventions

September 20, 2012

  • By-convention parameter binding SqlQuery overload
  • SqlCE relative path connection string UX issues with Migrations
  • Pluggable Conventions
  • Polish the conventions API
  • Breaking change

August 23, 2012

  • Make ObjectContext implement IObjectContextAdapter
  • Migrations multi-tenancy
  • Designer versioning
  • Async protection

August 9, 2012

  • Getting schema Information from providers
  • Using IDbDependencyResolver with existing IoC containers

August 2, 2012

  • CUD Batching
  • Bulk operations

July 26, 2012

  • Async
  • One-pagers
  • Initializer proposal

July 12, 2012

  • Model key caching
  • Migrations history table schema changes
  • Async immediate LINQ operators

July 5, 2012

  • Refactoring and unit tests

June 28, 2012

  • Code contracts

June 21, 2012

  • Code-based configuration

June 14, 2012

  • Making database connections in the test suite more configurable

June 7, 2012

  • Naming convention for static readonly and const fields
  • How will we handle breaking changes in EF6?
  • High-level ideas for using dependency injection with EF and specifics for the provider

May 31, 2012

  • Making EF code more testable
  • Code duplication in Async
  • Supporting MVC scaffolding

Updated Wiki: Nightly Builds

Updated Wiki: Getting and Building EF Runtime

Updated Wiki: Getting and Building EF Tools

Updated Wiki: Debugging EF Tools

Updated Wiki: Contributing


Updated Wiki: ProjectGuidelines

Updated Wiki: CodingConventions

Updated Wiki: Contributors

Updated Wiki: Issue Tracking

Updated Wiki: Known Issues

Viewing all 10318 articles
Browse latest View live




Latest Images