WPF application with static DbContext in ViewModel

I'm developing WPF application using MVVM, Code-First and the repository pattern. I need to have a background task, which processes webserver requests from clients and saves new data into database. The problem is each ViewModel has a property (Observ

Optimistic competition with Entity Framework and ORACLE

Trying to implement Optimistic Concurrency with Entity Framework 6 (Designer First approach) and Oracle database (ver 12). SQL Server has RowVersion attribute which can be used to track the changes, couldn't find any similar attribute in Oracle. Was

Moq - Updated with DbEntityEntry

I'm using EF6. The generated code is something like: public partial class MyDataContext : DbContext { public MyDataContext() : base("name=mydata") { } public virtual DbSet<Book> Books { get; set; } } Then I have a generic repository like:

Entity Framework has left the join of multiple tables

I'm using Entity Framework 6 and I have few entities and a query like the following: var results = (from e1 in dataContext.Entity1 .Where(x => x.Key1 == 1) from e2 in dataContext.Entity2 .Where(x => x.Key2 == e1.Key1) .DefaultIfEmpty() from e3 in da

Entity Framework TPC inheritance problem

I'd like to have Table Per Concrete type inheritance in my application: public class Row { public int Id {get;set;} public string Name {get;set;} } public class ExtendedRow : Row { public int Weight {get;set;} } Each of the classes need to be mapped

Entity Framework Foreign Key Mapping

I'm trying to determine what EF6 is telling me, and it's not making much sense to me, so I'm hoping someone here can clarify this. I'm setting up my FluentApi as so (composite keys in use in the DB, this is Code First from Database): modelBuilder.Ent

EF6: Use reference / search data with IQueryable

I want to use a pre-loaded lookup data from a list within a query. I need the query to return as IQueryable because it is used in a grid & being paged (not included here). I need the Labels to load from the lookup to avoid joins (more are in the actu

Expired timeout problem in lambda method for contains

I have this code: string[] splits = keyword.Split(' '); var fproducts = (from products in db.tbl_Product where splits.Any(item => products.Prod_Name_Fa.Contains(item) || products.shortDesc.Contains(item) || products.Prod_Code.Contains(item)) select p

EF Migrations: Creating a DbContext Instance

Is it possible to "tell" migration how to create MyDbContext instance? By default it uses a public parameterless constructor and searches for the connection string in AppConfig with the same as MyDbContext class. Can I tell somehow configure mig

Entity Framework 6 optional one-way relationship

I have two tables: Client ------------------------ Id (string) <-- PrimaryKey Name (string) Number (int) Department:* ------------------------ Id (int) <-- Primary key Name (string) ClientNumber (int?) Client (Client, virtual) ..... Now I want to cr

Entity Framework 6.0 custom entity builder logic implementation

I'm using EF 6.0 and want to add custom logic into/after default constructor execution of any class generated by Model.edmx file. Found that in deprecated EntityObject generator version there was partial void OnCreated method in each generated class

Entity framework 6 transaction

I need to insert new rows in two of my tables first table's auto generated id field is one of the field of second table .currently I'm using transaction for inserting data. My current code is given below using (var context = new ApplicationDatabaseEn

Code an SQL projection and a mapping at the same time?

This works to carve out a DDL object from an Address object from our database: public class DDL { public int? id { get; set; } public string name { get; set; } } List<DDL> mylist = Addresses .Select( q => new DDL { id = q.id, name = q.name }) .To

Much to a relationship, undesirable

I have many to one relationship defined within my model: Project.CreatedBy = ApplicationUser.Id: class Project{ [Required] public ApplicationUser CreatedBy {get; set;} } With mapping: modelBuilder.Entity<Project>().HasOptional(i => i.CreatedBy).W

IEquatable interrupts the loading of Entity Framework entities

I want to compare records to see if there are differences between them. Person table: ID Name Address -------------------------------- 1 John Smith 123 A Street 2 John Smith 123 A Street 3 John Smith 234 B Street Records 1 and 2 are "equal". Rec

Entity framework 6 filter child object

I'm trying to get data from database with use of EF6. I have two classes public class Manufacturer { public int Id {get;set;} public string Name {get;set;} public bool Enabled {get;set;} public virtual IList<Product> Products {get;set;} } public cla

ASP.NET Entity Framework Code Premier Migrarion

This a ASP.NET MVC with Entity Framework 6.1 Code First application. I need my application to CREATE the database if it doesn't exists and seed the tables with some data. Also I need to Migrate the database on application start if the model has chang

Complex type in the Database-first model of a DDD project

Let's say in my EF6 project [Database-first approach] I have a complex type called Address [just to clarify my complex type does not have any identity and is only a merge of aggregation of standalone data and it is not even responsible for its own pe

Entity Framework 6 Relationship Mapping 1 to 1 does not work

I am using Entity Framework 6 with an existing database and have migrated some data from an old custom authentication system. I have two models, one extending the scaffolded ApplicationUser (Identity) in MVC5, and the other a model of an old table. T

Mapping composite keys using EF code first

Sql server table: SomeId PK varchar(50) not null OtherId PK int not null How should I map this in EF 6 code first? public class MyTable { [Key] public string SomeId { get; set; } [Key] public int OtherId { get; set; } } I've seen some examples where

BreezeJS and Entity Framework 6.0.1

I'm trying to create a Breeze Web API controller and I'm wondering if it is possible with the default MVC/Web API project template that comes with Visual Studio 2013. Updating everything through the Nuget packet manager installs Entity Framework 6.0.