entity-framework

Does ADO.NET Entity Framework have a construct similar to Linq-To-SQL's GetTable<T>

I'm trying to do something similar in Entity Framework, that I'm very used to doing in Linq-To-Sql. Now my question is if EF has the same capability, that I'm unable to figure out. Linq-To-Sql: dataContext.GetTable<T>(); Would yield a Queryable collection of type 'T'. In Entity Framework I would like to do the same: //NOTICE: T...

How can I get an instance of a base class from an inherited class dynamically?

I've got a class public class foubar : fou fou has its properties and so does foubar I've created an instance of foubar and set values to all the properties including the base classes'. Now I need an instance of fou that has the property values that are in foubar. True, I could create a new instance of fou and write code that would popu...

SQL Server Compact Edition with Entity Framework

I try to use SQL Server Compact Edition with Entity Framework in Visual Studio 2008 SP1. Here's what I do: 1) I create a new project, of type Console Application. 2) I right-click on the project, select Add->New Item. 3) I choose to add a Local Database called Something.sdf 4) In the next page of the "Add New Item" wizard, I choose t...

How to use entity framework inheritance?

First off I'm a noob so please be gentle :-) I have a base object Company. I want to inherit this into a Customer object and a Vendor object. My problem starts with the fact that a given company can be a customer and a vendor at the same time. All the examples I have seen a use a property of the company and set it to either customer or v...

Can Entity Framework deal with multiple result sets (each from joined tables) from a stored procedure?

In Linq to SQL, I can't find an easy way to deal with multiple result sets returned by a stored procedure where each result set is from table joins. Each result set does not map directly to a table. (can't change this behavior). For now, it seems using a DataSet is a lot simpler. Can the current Entity Framework or the upcoming one, 4.0...

Where does EF store the mapping view, in MetadataWorkspace, EntityConnection or in ObjectContext and is it worth it to pregenerate views?

I am currently transitioning an application over from LINQ-to-SQL and I've been running into a problem. LINQ-to-SQL offered a way to query any Table/Column-attributed type (which was the default mapping model) through any DataContext through the GetTable<T> function, which analyzed the type and then created the appropriate SQL. Even th...

How do I create a read only entity in the entity framework?

I am loading a graph of related entities from the database using ADO.NET MVC and the Entity Framework. One of the entities needs to be modified in memory, but not have changes persisted back to the database when other entities in the graph are changed. At this time I have attempted to use the MergeOption.NoTracking and the MergeOption.O...

database relationship to many tables and representation in entity framework

2 part question: 1st What is the best way to setup a table/relationship structure given the following scenario: I have many tables that store different kinds of data (ie: books, movies, magazine - each as different tables) and then one table that stores reviews that can link to any of the table types. So a row in the review table can ...

Binding entities with foreign key to datalist

I have the following code: var devices = from d in ctx.Devices.Include("DeviceGroups") where d.DeviceEnabled == true select d; dlTerminals.DataSource = devices; On the front end i do the following: <asp:DataList ID="dlTerminals" runat="server" DataKeyField="DeviceId" GridLines="None" RepeatColumns="2" RepeatDirection="Horizon...

It has a DefiningQuery but no InsertFunction element... err...

This thing is driving me crazy, and the error is quite meaningless to me: Unable to update the EntitySet 'TableB' because it has a DefiningQuery and no element exists in the element to support the current operation. My tables are put like this: TableA int idA (identity, primary key) ... TableB int idA (FK for TableA.idA) int val ...

.Net Framework Data Provider not found on host.

I have a working web site using Linq to Entities, on a MySQL database. Last night I installed the MySQL connector 6.0 for .NET, and all was good on my local machine. I assume I now have some GAC to Bin migration to do on the host. Does anybody know what files I must transfer and what I must do to my web.config? ...

How to use Entity context in entity class for performance?

Suppose I have project MyData, then I add MyDb.edmx with EF wizard. In My database, I have table Person. Then I will get an entity Person in EF model. Then I want to extend this Person by partial class in a separated file person.cs like: namespace MyData { public partial class Person { [DataMember] public int ...

Backup and Restore through the Entity Framework.

I'm working with an SQL Server database with about 50 tables and plenty of relationships between those tables. I have already written a backup and restore function which will retrieve all data from the model, export it to XML which it could then import again into a clean database. But maintaining this import/export is a lot of work when ...

TM1 API for LinqToEntities

IBM Cognos TM1 is a multidimensional database that my company thinks is the latest and greatest. I've been to the classes and, sure, it is nice for analysis. Of course the finance people in my company only see the Excel Add-In or Excel-like website and think "that's all I need for a data entry application!" My response is "I thought you ...

Retrive data from two tables in asp.net mvc using ADO.Net Entity Framework

Please read my question carefully and reply me. I have two tables as table1 and table2. In table1 i have columns as AddressID(Primary Key),Address1,Address2,City In table2 i have columns as ContactID(Primary Key),AddressID(Foriegn Key),Last Name,First Name. By using join operation i can retrive data from both the tables. I created a...

Why is Entity Framework ignoring the Take() method when generating SQL?

I am using the .Skip and .Take methods with Entity Framework. The .Skip call is being honored when generating the SQL. The .Take is not. This code: public IList<DocPullRun> GetDocRunsPaginated(int startRowIndex, int maximumRows) { Logger.Debug("GetDocRunsPaginated: startRowIndex: {0}, maximumRows: {1}", startRowIndex...

Char datatype in relationship entity framework problem

I have a 3rd party database where the primary key is a char datatype. When I run my query, I use an include to include the child table. The count is zero though. I look at sql profiler and results are returned. The only thing I can see is an issue with the relationship columns being char. Any solution for this? ...

Entity Framework 4, hybrid relationship implementation

We have application where there is a layer between entities which provides relationship. Chair -> RelationTable -> Legs (In Chair)So Chair id # 1234 (In RelationTable)In RelationTable 1234 -> 1, 1234 -> 2, 1234 -> 4 (In Legs)Leg id #1, Leg id #2, Leg id # 4 Now i am looking into implementing EF4 as they have POCO. Is it possible to...

Ado Entity Framework Adding Data

Hi everyone, I'm having a little trouble with my Entity add functionality. Setup For simplicity, I have in DB with 4 tables, Customer, Address, Area, Location. Customer stores basic customer details ie. Id, Name, Username, Password, etc. Address stores street name, street number, etc. Area stores area name and area code. Location st...

Entity Framework v2 doesn't support sql 2000?

I installed the beta 2 of Visual Studio 2010 today. I went to test out the new entity framework stuff (to see if my "issues" from v1 were fixed.). I started adding a new connection string, but when i put in my information for sql 2000 it said "this server version is not supported. you must have Microsoft sql server 2005 or later.". Did...