entity-framework-4.1

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

怎甘沉沦 提交于 2019-12-06 09:56:28
问题 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

Entity Framework RC1 DbContext query issue

我怕爱的太早我们不能终老 提交于 2019-12-06 09:39:01
I'm trying to implement the repository pattern using entity framework code first rc 1. The problem I am running into is with creating the DbContext. I have an ioc container resolving the IRepository and it has a contextprovider which just news up a new DbContext with a connection string in a windsor.config file. With linq2sql this part was no problem but EF seems to be choking. I'll describe the problem below with an example. I've pulled out the code to simplify things a bit so that is why you don't see any repository pattern stuff here. just sorta what is happening without all the extra code

EF4.1 Exception creating Database with table-per-hierarchy inheritance

丶灬走出姿态 提交于 2019-12-06 07:18:10
问题 I have created a very simple project to demonstrate table-per-hierarchy inhertiance. In my unit test which tries to generate the database, i get one of a number of errors depending on the config: without the Required() method Map<InActiveUser>(x => x.Requires("IsActive").HasValue(false)); Map<ActiveUser>(x => x.Requires("IsActive").HasValue(true)); delivers: System.Data.DataException : An exception occurred while initializing the database. See the InnerException for details. ----> System.Data

How to have different connection string for different users in Entity Framework

左心房为你撑大大i 提交于 2019-12-06 07:16:34
问题 I have a requirement in which I need to have different connection strings for different users. The idea is to have the username and password supplied at the login screen to be used as the username and password of the connection string. Thus making application to use different connection string for different user, and to use this connection string throughout the application. How to get this setup in EF 4.1 PS: I am using DbContext 回答1: Thanks to Kevin Junghans This is how I have done it. in

Problem with SaveChanges() Entity Framework 4.1

懵懂的女人 提交于 2019-12-06 06:01:52
I am having problem with saving the changes to database. I am updating the model A in my controller, however when I save the changes using SaveChanges() I end up having a duplicated item in database for B. After the UpdateModel() is called I inspected the Bs property and it was as I expected however right after the SaveChanges() is called if I inspect the Bs property I will see that the Id is completely different (new Id and new entry). My class is similar to this: public class A { [HiddenInput(DisplayValue = false)] public int AId { get; set; } public string Name { get; set; } public virtual

Entity Framework 4.1 Code First - Should many relationship ICollections be initialised

馋奶兔 提交于 2019-12-06 05:52:43
问题 In Entity Framework 4.1 when creating a POCO, should the class be coded to initialise the Many relationships or is there some reason to allow the Entity Framework to have control over these properties? public class Portfolio { private ICollection<Visit> _visits; public virtual ICollection<Visit> Visits { get { if (_visits == null) { _visits = new List<Visit>(); } return _visits; } set { _visits = value; } } } Or public class Portfolio { public virtual ICollection<Visit> Visits { get; set; } }

Is it considered bad design to pass a repository interface as an argument to a method on a domain class?

痞子三分冷 提交于 2019-12-06 05:42:49
Our domain model is very anemic right now. Our entities are mostly empty shells, almost purely designed for holding values and navigating to collections. We are using EF 4.1 code-first ORM, and the design so far has been to shield our novice developers against the dreaded "LINQ to Entities cannot translate blablabla to a store expression" exception when querying against the context during early iterations. We have various aggregate root repository interfaces over EF. However some blocks of code in the impls seems like they should be the domain's responsibility. As long as the repository

EF Code First mapping for collection

喜你入骨 提交于 2019-12-06 05:42:05
问题 I'm using EF 4.1 RC Code first. I have a many to many relation working with a composite PK in the junction table Friends. We explicitly need a separate Friends class (don't ask) which represents our junction table. Our goal is to be able to control the delete process from the User entity. Please read this before reading the rest: http://mocella.blogspot.com/2010/01/entity-framework-v4-object-graph.html. So, we managed to create our composite PK but this broke our mapping for the collection.

Entity, dealing with large number of records (> 35 mlns)

对着背影说爱祢 提交于 2019-12-06 05:10:50
问题 We have a rather large set of related tables with over 35 million related records each. I need to create a couple of WCF methods that would query the database with some parameters (data ranges, type codes, etc.) and return related results sets (from 10 to 10,000 records). The company is standardized on EF 4.0 but is open to 4.X. I might be able to make argument to migrate to 5.0 but it's less likely. What’s the best approach to deal with such a large number of records using Entity? Should I

could not load assembly 'system.data.entity, version 4.2.0.0,

对着背影说爱祢 提交于 2019-12-06 05:03:11
问题 I have this error message could not load assembly 'system.data.entity, version 4.2.0.0, culture=neutral,publickeytoken=b77a5c561934e089' or one of it's dependencies. the system cannot find the file specified and I cannot use the entity framework at all. it happened after uninstalling June 2011 CTP from my computer, and I have no idea what to do. I reinstalled the visual studio again and with no help. Does anyone have any idea? 回答1: after reinstalling visual studio i found another insatnce of