entity-framework-4.1

Lazy / Deferred loading of links not on time?

倖福魔咒の 提交于 2019-12-04 19:27:25
Did someone experience the following? Validating objects with fields that refer to other Entities would throw you an error stating that the field wasn't present and that when you would debug the program and you would inspect the entities that the fields are populated. This has happened to me on two occasions now and it seems to be some problem with lazy loading, as if the lazy loading did not give the answer fast enough. We have this (simplified) model where class Survey { ... public bool Enabled {get; set;} [Required] public virtual OrganisationalUnit OU {get; set;} ... } If we would just do

EF4.1 hangs for 120 seconds when using Microsoft.ApplicationServer.Caching.DataCacheFactory

为君一笑 提交于 2019-12-04 18:21:43
I have a consistent, repeatable 120 second hang whenever the application calls this.cacheProvider.Add(new CacheItem(cacheKey, data, this.regionName), cachePolicy); at line 60 of the CachedDataSource.cs of the sample. . The .Add method is internal to Microsoft's DLL and I don't have code to it. Here are my parameters: cacheKey = "listofCompanies" data = // this is an EF 4.0 database first model class with 70 entries... result from IQueryable this.regionName = "companies" Reproducing the error: I have a database-first EF4.0 project that I recently upgraded to 4.1 by adding the "EntityFramework"

Table Mapping problem

老子叫甜甜 提交于 2019-12-04 18:20:38
I am using entity framework 4 in my current project, to read data from several table. Compare using ADO.net, it EF is very easy, with simple code that can do lots of work or me. But there is one problem... e,g there is and exiting table call Table "MTable" i only want to query two column from this table, however this table is share with other two ppl who are also working on it. they might add column or modify constrains on this table. Only one thing i am sure is that, the two column i want to query they wont delete it or rename it. My application is runing now, but from time to time it break

How to add a column to a link table with code first

大憨熊 提交于 2019-12-04 17:52:19
I have a ResearchDatabase entity that has a many-to-many relationship with a Subject entity. i.e. a Research Database belongs in one or more Subject Categories, and a Subject Category contains one or more Research Databases. In my ResearchDatabaseConfiguration file I have the following mapping: HasMany(rd => rd.Subjects) .WithMany(s => s.ResearchDatabases) .Map(m => { m.MapLeftKey("DatabaseId"); m.MapRightKey("SubjectId"); m.ToTable("DatabaseSubjects"); }); OK, no problem. Works. Creates a link table. Now I have received a new specification. The ordering of the Research Databases in each

Why is MVC3 not scaffolding my foreign key columns

瘦欲@ 提交于 2019-12-04 17:24:53
I'm trying to use MVC 3 with EF 4.1 using code first and am following Scott Guthries tutorial http://weblogs.asp.net/scottgu/archive/2011/05/05/ef-code-first-and-data-scaffolding-with-the-asp-net-mvc-3-tools-update.aspx . The issue I'm having is that when I create the products controller and the related scaffolded views, there is no "category" column being created in any of the views ("edit", "create", "index" etc), which according to the tutorial should be created. I've traced the reason why the column is not being shown is because of the t4 templates... it is failing a check to see if it is

EF 4.1 SaveChanges not updating navigation or reference properties

你离开我真会死。 提交于 2019-12-04 16:05:43
问题 I'm using code first and can add records without a problem. The database is created properly and is seeded without any problems. But calling SaveChanges() in my Edit action only updates the entity, not any of the navigation or reference properties. A simplified version of my model: public class Contact : IMyBaseObject { public Contact() { this.Delete = false; this.ContactTypes = new HashSet<ContactType>(); } public int Id {get; set;} public string Name {get;set;} public bool Delete {get;set;}

Passing multiple Include statements into a repository?

久未见 提交于 2019-12-04 16:05:16
问题 I am trying to figure out a way to pass a collection of include statements into my repository so that I can have it include specific entities. Below is some sample code from my repository. public TEntity GetById(Guid id) { return id != Guid.Empty ? GetSet().Find(id) : null; } private IDbSet<TEntity> GetSet() { return _unitOfWork.CreateSet<TEntity>(); } The GetByID method calls the GetSet to return the entity set. I was thinking, if I could somehow pass in a collection of entities to include

How to configure multiple Foreignkey referancing to same table from main table using EF Code First Fluient API

给你一囗甜甜゛ 提交于 2019-12-04 15:28:41
I have to design a web application using existing database of desktop application. As per existing database i have below class public class Company { #region Primitive Properties public virtual int CompanyID { get; set; } public virtual string CompanyName { get; set; } public virtual bool IsCustomer { get; set; } public virtual string CustomerCode { get; set; } public virtual bool IsPotentialCustomer { get; set; } public virtual bool IsSupplier { get; set; } public virtual string SupplierCode { get; set; } public virtual bool IsPotentialSupplier { get; set; } public CompanyCategoryCodes

Entity with many-to-many relationship creation fails after upgrading to RC

喜欢而已 提交于 2019-12-04 14:41:23
I've got a project with 3 simple tables, a couple of POCO classes, and a DBContext created with code, no edml file. The following code setup used to work with the beta of Entity Framework code-first, I've edited the DbContext code since the ModelBuilder changed from the beta to RC Tables (simple tables many-to-many table has fields declared as foreign keys with cascade deletion): CREATE TABLE [dbo].[Bookings]( [ID] [int] IDENTITY(1,1) NOT NULL, [StartDate] [datetime] NOT NULL, [EndDate] [datetime] NOT NULL, [AccountId] [varchar](50) NOT NULL, CONSTRAINT [PK_Bookings] PRIMARY KEY CLUSTERED (

Deploy Entity Framework Code First Database

六眼飞鱼酱① 提交于 2019-12-04 14:37:24
问题 I have an ASP.NET MVC 3 application using an Entity Framework (4.3.1) Code First database. Now I would like to create a comprehensive zip file containing the database, the application package generated by Visual Studio 2010 and a script to deploy everything to a Windows 2008 server with IIS7 and SQL Server 2008 with a prepared (but empty) database. I don't foresee any problems with the deployment of the application package, but I'm unsure of what approach to use in deploying the database. The