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
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
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:
I have 2 entities which depict Post, and Comments. public class Post { public int Id { get; set; } public ICollection<Comment> Comments { get; set; } //other properties //Unmapped property public int NumberOfComments { get; set; } } public class Com
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
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
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
OK I can delete a single item in EF6 like this: public void DeleteUserGroup(MY_GROUPS ug) { using (var context = new MYConn()) { var entry = context.Entry(ug); if (entry.State == EntityState.Detached) { context.MY_GROUPS.Attach(ug); } context.MY_GROU
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
I created a new .NET project and added ADO.NET EF 6. I went through the EF wizard and choose Code First from Database. Then I selected a table. Let's call it "Product". This created "public partial class Product" and "public parti
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
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
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
I cannot seem to resolve what appears to be a common issue with Entity Framework 6. I have reviewed the many topics related to this issue on SO, and am unable to find a solution that works for my particular case. I have up until this point been devel
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
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
I have 3 tables, Person | Book | PersonBook PersonBook table is relaton table between Person and Book Person Book PersonBooks Id Name Id Name Id PersonId BookId 1 rick 1 SQL 1 1 1 2 phil 2 Asp.Net 2 1 3 3 scott 3 MySql 3 2 4 4 C# 4 3 2 5 3 3 6 3 4 I
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
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
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
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
I would like to wait for this query before proceeding to do anything else. I have seen several question on this topic but none of those are using custom function in the query, which is making it little tricky. Is it even possible to use await with fo
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
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
I'm attempting to do the following: public class class1() { public int Id {get;set;} [ForeignKey("Class2")] public int Class2Id {get;set;} public virtual Class2 Class2 {get;set;} } public class class2() { public int Id {get;set;} [Required] publ
I am at the beginner level of learning MVC5 using EF6. Basically I am trying to use a connection string defined in machine.config rather than using web.config whilst creating the ADO.NET Entity Data Model. The reason why I am using machine.config for
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
From my integration test: // Act Stopwatch w = new Stopwatch(); w.Start(); userService.Create(userDTO); w.Stop(); public void Create(UserDTO userDTO) { var user = userDTO.ToEntity(); _context.Entry(user).State = EntityState.Added; _context.SaveChange
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
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.