entity-framework

How do I mock a Where clause in EF4

I am re-writing this question to make it clearer what I need to do. I am trying to use Rhino-Mock to test: public IQueryable<TxRxMode> GetAllModes() { return m_context.TxRxModes.Where(txRxMode => txRxMode.Active); } Here's the code: var context = MockRepository.GenerateStub<IProjectContext>(); //Returns an empty ...

Bigint field being generated as int instead with entity framework

Hello I have a field in a table which is declared as bigint, but Entity framework displays it as Int This is causing me a problem because the model field is int32 but linq then tries to save as int64 If I change the field in the property to int64 I get type mismatch errors Has anyone ever encountered this? Paul ...

How do I map a stored procedure to a custom type in entity framework?

Hello I have a stored procedure which returns a couple of fields from a table that has many fields I need to get this into a custom type in my model I have added my entity and changed the function import to return objects of the new type but now I get a problem where the columns are not mapped Can anyone help? Cheers Paul ...

Exception about foreign key

Here is the inner exception: InnerException: System.Data.UpdateException Message=Entities in 'OrganizerDBEntities.Assignments' participate in the 'CourseId' relationship. 0 related 'Course' were found. 1 'Course' is expected.` I have three tables (Folder, Assignment, Course). The Assignment table has a primary key called Assignm...

Use MSBuild to build Entity Framework Model without using the Project File?

I am in the process of build a script for a fairly big project. One of the projects require an Entity Framework Model to be compiled into a library. Due to the way the build server works, all builds are hand crafted to manage the various deployment scenarios without affecting the developers and the project files. Is there anyway to gene...

How do I create a new sql server session in entity framework?

How do I create a new sql server session in entity framework? Thanks~ ...

IQueryable to string[] array?

Hello I have this piece of code: public string[] GetUsergroupRoles(string username) { var qry = from ug in _entities.Usergroups from r in _entities.Roles from u in _entities.Users where u.Username == username group r by new { ...

LINQ to Entities - Support for Closures (Lambdas) ?

Hey all I've been working around a problem I have when using LINQ to Entities when using closures. Apparently, L2E does not support closures. Meaning: var users = from user in UserRepository.FindAll() select new UserDTO { UserId = user.UserId, Tickets = from ticket in TicketReposit...

How, WCF Ria Services can make a customised entity, known at client-side?

I constructed my Entity Model. One of my business objects,let's call it Store has a spatial data type. Very quickly I figured out that spatial fields aren't mapped via EF4. However I struggled my way out, by editing the xml declarations defining a query like the following: <EntitySet Name="Stores" EntityType="Eltrun.OnShelfAuditModel....

Entity Framework creating new record instead of modifying existing one

I'm using Entity Framework with an AS.NET MVC application. I need to allow the user to create new records and modify existing ones. I am able to fetch existing records no problem, but when I pass back in the edited entity and try to save it it creates a new one and saves it and leaves the original unmodified. I am getting the object fro...

Entity framework: Access / modify the Command Tree or otherwise provide custom mapping C# functions

Hello, I'm investigating a method of providing transparent bi-temporal versioning of entities with Entity framework 3.5 or 4.0. What I want to do: When an entity is saved, the former entity has to be copied into a separate table, for example, if the entity is Customer, it will be saved in Customer_AUD. Upon retrieval, based on date/ver...

MSDTC Configuration Automation

We are developing a large scale business application using most new technologies through .NET 3.5 and we are using EF as DataAccessLayer in our architecture in addition to Transaction management which automatically uses System.Transaction and MSTC. We need to deploy this application by ClickOnce method for over 300 end-user in each custo...

EF4 Update model from Database VistaDB issue

Does VistaDB support 'Update model from Database' feature in EF4? I'm receiving this message: " ... 'System.ArgumentNullException' 'Value Cannot be Null' Parameter name: providerInvariantName" ...

How to create a relationship between table and view in the Entity Framework

I have an Entity Framework model that was generated by the Visual Studio 2008 wizard based on a Sql Server 2008 database. The model has a view that logically is joined in a many-to-many relationship with another table through a join table (enforced in the database by an insert/update trigger). Both tables and the view are part of the...

ASP.NET MVC w/ Entity Framework - UpdateException

Hi All, I am encountering a problem when I go to update an object in my database using Entity Framework. Firstly, the concept is: A user can be a member of a group, hence a Group contains Users. To model this in the database, I have the following structure: Users: ID Name etc. Groups: ID Name GroupMembers: ...

Cloning data on Entity Framework

I am creating software where user can create new product based on older product. Now I need to make copying / cloning operations with Entity Framework. First I started writing like this: foreach(sourcedata1 in table1) { ... create new table ... copy data ... create Guid ... add foreach(sourcedata2 in table2) { ...

Do I need anything other than VS2010 beta 2 to use "Code Only" in Entity Framework 4?

Is it possible to use "code only" with Entity Framework in an out-of-the box VS2010 Beta 2, or do I need some additional download? ...

Considerations for implementing LINQ to SQL or Entity Framework now, intending to use NHibernate later

I've got a deadline for an initial release of a client-server application that will have lots of iterative releases subsequently. NHibernate is the ORM of choice, largely by reputation and my desire to gain experience with it. The problem is that I haven't even had a chance to spike NHibernate yet, and I'm afraid that doing so is going...

How do I get Entity Framework to use interfaces on the generated classes?

I have a project where the client is using Entity Framework, and I'm trying to abstract away the generated classes from the rest of the application. One generated class is Category and it has say Type as a property. I've created an interface that I want Category to implement, like this: public interface ICategory { string Type { g...

LINQ sorting, doesn't work

I have a LINQ query like this: from i in _db.Items.OfType<Medium>() from m in i.Modules from p in m.Pages where i != null && i.Type == 1 && i.Published == true && p.PageId == 2 select p I use the query like this because I have strongly typed view (ASP.NET MVC). I need to have items sorted by the i.Sort property. orderby i.Sort and i....