Questions tagged [entity-framework-6.1]

Entity Framework 6.1 is a minor update to Entity Framework 6 and includes a number of bug fixes and new features.

Entity Framework 6.1 is a minor update to Entity Framework 6 and includes a number of bug fixes and new features. The new features in this release include:

  • Tooling consolidation provides a consistent way to create a new EF model. This feature extends the ADO.NET Entity Data Model wizard to support creating Code First models, including reverse engineering from an existing database. These features were previously available in Beta quality in the EF Power Tools.
  • Handling of transaction commit failures provides the new System.Data.Entity.Infrastructure.CommitFailureHandler which makes use of the newly introduced ability to intercept transaction operations. The CommitFailureHandler allows automatic recovery from connection failures whilst committing a transaction.
  • IndexAttribute allows indexes to be specified by placing an [Index] attribute on a property (or properties) in your Code First model. Code First will then create a corresponding index in the database.
  • The public mapping API provides access to the information EF has on how properties and types are mapped to columns and tables in the database. In past releases this API was internal.
  • Migrations model change detection has been improved so that scaffolded migrations are more accurate; performance of the change detection process has also been greatly enhanced.
  • Performance improvements including reduced database operations during initialization, optimizations for null equality comparison in LINQ queries, faster view generation (model creation) in more scenarios, and more efficient materialization of tracked entities with multiple associations.
  • Ability to configure interceptors via the App/Web.config file (allowing interceptors to be added without recompiling the application).
  • System.Data.Entity.Infrastructure.Interception.DatabaseLogger is a
    new interceptor that makes it easy to log all database operations to a file. In combination with the previous feature, this allows you to easily switch on logging of database operations for a deployed
    application, without the need to recompile.
254 questions
30
votes
6 answers

store only date in database not time portion C#

I have a test class and an ExecutionDate property which stores only date but when we use [DataType(DataType.Date)] that also stores the time portion in database but I want only date portion. public class Test { [Key] public int Id { get;…
KARAN
  • 1,023
  • 1
  • 12
  • 24
18
votes
3 answers

How to totally lock a row in Entity Framework

I am working with a situation where we are dealing with money transactions. For example, I have a table of users wallets, with their balance in that row. UserId; Wallet Id; Balance Now in our website and web services, every time a certain…
Zapnologica
  • 22,170
  • 44
  • 158
  • 253
18
votes
2 answers

SetExecutionStrategy to SqlAzureExecutionStrategy with DbMigrationsConfiguration?

I saw a post today about implementing SqlAzureExecutionStrategy: http://romiller.com/tag/sqlazureexecutionstrategy/ However, all examples I can find of this use a Configuration that inherits from DbConfiguration. My project is using EF6 Code First…
16
votes
3 answers

Entity Framework 6.1 Updating a Subset of a Record

I have a view model that encapsulates only some of the database model properties. These properties contained by the view model are the only properties I want to update. I want the other properties to preserve their value. During my research I…
Caster Troy
  • 2,796
  • 2
  • 25
  • 45
14
votes
1 answer

Adding Inner Join to DbScanExpression in Entity Framework Interceptor

I'm trying to use an Entity Framework CommandTree interceptor to add a filter to every query via a DbContext. For the sake of simplicity, I have two tables, one called "User" with two columns ("UserId" and "EmailAddress") and another called…
13
votes
1 answer

entity framework code first migration keep existing data

I am using EF 6.1 and I use code first approach with an existing database with data in a production environment. Is it possible at all to migrate model changes and keep the existing customer`s data?
Pascal
  • 12,265
  • 25
  • 103
  • 195
12
votes
4 answers

Entity Framework 6: is there a way to iterate through a table without holding each row in memory

I would like to be able to iterate through every row in an entity table without holding every row in memory. This is a read only operation and every row can be discarded after being processed. If there is a way to discard the row after processing…
11
votes
1 answer

entity framework Remove vs EntityState.Deleted

What is the diff between these two statements? Both should delete an entity. _context.Entry(new Schoolyear { Id = schoolyearId }).State = EntityState.Deleted; _context.Schoolyears.Remove(new Schoolyear { Id = schoolyearId }); and for those who…
Elisabeth
  • 20,496
  • 52
  • 200
  • 321
9
votes
1 answer

Preventing "'System.DateTime' failed because the materialized value is null"

I would like to prevent this from happening but in a different way rather than setting type of DateCreated to nullable DateTime. The full exception reads like this: The cast to value type 'System.DateTime' failed because the materialized value is…
9
votes
1 answer

EF6 code first: How to load DbCompiledModel from EDMX file on startup?

I want to reduce startup time in EF6 by caching the DbCompiledModel to disk. It's easy to write the EDMX file for a DbContext: EdmxWriter.WriteEdmx(myDbContext, XmlWriter.Create(@"C:\temp\blah.xml")) And it's easy to pass a DbCompiledModel to the…
Brendan Hill
  • 3,406
  • 4
  • 32
  • 61
9
votes
2 answers

How to create spatial index using EF 6.1 fluent API

Well, the question is clear enough. Is it possible to create spatial indexes using Entity Framework 6.1 fluent API?
9
votes
2 answers

using .include in entity framework create huge query?

I wasn't expecting a generated query like this... let go back, if I keep one include, the query look good, it does a simple left join Query: using (var db = new Context()) { var data = db.MainTables.Include(x => x.LookupTables) …
Fredou
  • 19,848
  • 10
  • 58
  • 113
8
votes
0 answers

EF6 database first - the relationship was not loaded because the type is not available

I an using EF6 database first design in a web application. There is one entity that is involved in two 1-to-many relationships (the E2 in this example): E1 <--- E2 ---> E3 E1 and E3 both have a navigation property for E2 (called E2s). When I try…
Andrew
  • 81
  • 3
7
votes
2 answers

Persisting and retrieving serialized entity property with Entity Framework 6.1 code first

Example: Let's say I have these three classes. Foo is a proper Entity Framework entity with a DbSet whereas I want my EF DbContext to be unaware of Bar and Baz because I have flagged Foo's Bar property with my made up SerializedColumn attribute. By…
7
votes
1 answer

EntityFramework Stored Proc Function Import is it possible to read async?

I'm using EF 6.1.1 and Database First. When I import a stored proc into the edmx and generate the DBContext it looks like this: return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction("TestSP", params[]...) That returns an…
1
2 3
16 17