Questions tagged [entity-framework-4.1]
This tag is for the ADO.NET Entity Framework 4.1, the first release of EF to ship separately from the .NET framework. It builds upon the core Entity Framework included in .NET 4.0 and was released to the public in March 2011.
3,111
questions
0
votes
0
answers
192
views
Code First EF call a stored procedure from a different database to later do insert data in c#
I have an application where I am using Code first migrations and EF and I have my connection string in file App.config and all that goes with Code first migrations workflow and all is working fine. ...
0
votes
3
answers
1k
views
How do I create relationships in EF Core?
I am building a ASP.NET Core 2.0 application with a Web API backend and an Angular 5 front end. For my data access layer I am using Entity Framework Core.
For example, I have two models below that ...
-2
votes
1
answer
270
views
Entity Framework is not working in class library project
I have created a class library project in VS2010 ultimate with .net 4.0 and Entity fwk-4.1.
After adding a ref to the Entity framework dll, I am not able to use the Data Annotation attributes like '...
0
votes
0
answers
85
views
Partial Methods Entity Framework
I am trying to implement partial methods with Entity Framework Code first
using System;
using System.Collections.Generic;
namespace CodeFirstPortalEntity.Models
{
public partial class ActionItem
...
1
vote
0
answers
1k
views
Can we install Entity Framework 6.1.3 in Global Assembly Cache and use Entity Framework 4.1 as private assembly?
I have a requirement where in my existing modules are using Entity Framework 4.1 and would continue to use the same for few years and my new modules would use Entity Framework 6.1.3. So I am trying to ...
0
votes
1
answer
64
views
Migration taking a lot of time to apply to the DB
I am working on an Entity framework project(code first) and got a situation to alter the table.
I have run the add-migration for the same and got the migration file.
when i try to apply this migration ...
11
votes
4
answers
2k
views
Entity Framework 4.2, Unable to set Identity Insert ON
I would like to add records in bulk to a table with given ID's so I could build a hierarchy for displaying records in a tree view fashion. I can singly add records which works fine and I don't set the ...
0
votes
0
answers
336
views
Entity Framework Performance Considerations
We have an application running that makes and intensive usage of EF version 4.1. Right now an update is not scheduled, but this is not the point.
We are going under a process of huge optimization as ...
0
votes
0
answers
193
views
mapping the keyword(UserRole) in entity framework
In entity framework, database first approach, I have 3 tables [userrole], [role],[user]. In that when I am updating edmx file, then [userrole] is not coming in models classes.And [role] table is ...
0
votes
1
answer
552
views
Visual Studio 2013 Entity Framework 4.0 Oracle 11.2 and ADO.NET Issue with EDMX file
How can I use Entitiy Framework 4.0 within Visual Studio 2013 to connect with Oracle ? I've a working solution for Visual Studio 2010 and Entity Framework 4.1 and Oracle 11.2 version.,But when I'm ...
1
vote
2
answers
704
views
MVC Design query on Controller/Models
A few queries on EF.
Questions -
Should the methods that directly use database context object be part of Controller classes or Models?
ContactManagerContext.cs (which I am considering as a DAL layer?...
0
votes
2
answers
7k
views
Import Excel file data into Sql server using asp.net
I want to import excel file data in to SQL Server but this gives an error as shown below:
external table is not in the expected format xls
I am working on windows 8.1 OS and excel 2013. I am using ...
13
votes
1
answer
2k
views
Entity Framework with interfaces does not work - what the best way to handle the same?
I am using Entity Framework and would like to use TPH with interfaces. So I have a created an interface, "ICustomer", which maps to "SimpleCustomer" and "DiscountedCustomer" class as shown below. ...
0
votes
1
answer
218
views
Trackable entities Primary key violation EF 4 Issue
My situation is very wierd. We have a .NET 4.5 Application that uses Tracking Entities using EF 4. Everything works fine in our DEV/QA/UAT environment. But EF fail in Production with a Primary key ...
0
votes
2
answers
80
views
Register changes in the ViewModel on Entity modifications
I have an observableCollection containing several viewModels which are bound to an entity model each. The viewModel additionally contains several calculated text values:
public class SampleViewModel :...
1
vote
2
answers
85
views
Entity Framework and relationships with 1: 0..n relationships, what to do when it is 0?
In the application I support, there are times that associations can be null as the client has not submitted the data yet. I don't know of any other way to handle this other than doing a null check. ...
0
votes
1
answer
32
views
EF 4.1 Return Results from Stored Procedure
I'm new to EF and have just created a new stored procedure to return some basic info
CREATE PROCEDURE GetTop10Clients
@AccountId NVARCHAR(50)
AS
BEGIN
SET NOCOUNT ON;
SELECT TOP 10
...
2
votes
0
answers
218
views
Entity Framework Many To Many returns null
I have Many To Many relationship defined and when I try to query for the records that should be in the map I get null.
public class Record
{
public int RecordId { get; set; }
...
1
vote
1
answer
814
views
Is it possible to add two table's data in Seed method in Entity Framework(Code-first)?
In my DataLayer I have this 'Seed' method:
protected override void Seed(Context context)
{
User u1 = new User()
{
UserName = "dayan",
...
1
vote
0
answers
446
views
Best way to migrate from EF4 to EF6
I have an existing application based on EF4 model first which I need to upgrade to use EF6.
It includes a number of inherited tables (Table Per Type), so ideally
I want this to be maintained after ...
0
votes
1
answer
27
views
How do you handle application that displays only views with EF4 plus Repository Pattern?
I have database that has 5 views (SQL Server 2008) and the client requires a front-end web (MVC4) to view the data with filters. I am using Entity Framework 4 to map to the database...Not sure how to ...
5
votes
2
answers
939
views
Inserting a decimal into sql cause inserting a zero number Instead of a decimal number near zero
During insert a float number like 0.0001 into sql from my code, the result is a 0.0000 in database. here is definition of my table column:
decimal(20,15)
Here is the definition of class field:
...
-1
votes
1
answer
1k
views
Display list of related entities in MVC view
I have a Table ECmain that has a relationship with 2 other tables, Notes and Email.
I want to access the data in the view so that a list of toes will appear for every record in ECmain and be editable....
0
votes
1
answer
143
views
Inheritance with EF Code First – Table per Type (TPT)
I'm tryng to use Table per Type approach to do a inheritance with EF Code First. My actual structure s like this:
public partial class Person
{
public int ID {get; set;}
public string Name { ...
8
votes
1
answer
8k
views
Ordering Column Attributes in Entity Framework
I am using Entity Framework in my application,so I have mapped my property objects to database objects. The property objects have been defined using Column attribute.
Now,I want to order them,but I ...
0
votes
1
answer
3k
views
Custom Functions with Entity Framework
How to use Custom Functions with Entity Framework?
I'm trying to Call model-Defined Functions with Entity Framework. I use .Net Framework 4.5
I'm opening the Entity Model (.edmx) file in XML. I'm ...
0
votes
0
answers
675
views
Entity Framework SQL Connections are not getting closed or disposed
I'm using Entity Framework with Repository Pattern, but we have requirement to call stored proecedure, so we ended up in creating DAL Class with EF DBContext has local private variable in DAL Class,
...
1
vote
1
answer
537
views
Entity framework with IN Clause in Repository Pattern
I looking for some help on how to implement IN clause in the repository pattern. Rather than making single call for each and every record, I will have set of IDs, pass on this IDs to Context to get ...
-1
votes
1
answer
26
views
To use JOIN or UNION
I am supporting a legacy application which has a LINQ code which goes like this:
query1 = (from s in DBContext.Table_A JOIN DBCOntext.Table_B ON A.ID=B.ID
where a.SUPERVISOR = '9999' Select new ...
0
votes
1
answer
691
views
Complex Query LINQ Lambda
I am trying to extract data in a single query.
Since it involves many tables, I am sort of stuck at the grouping part.
I do not have enough reputation to post image of my table design.
So, I am ...
2
votes
2
answers
1k
views
EF 6 OriginalValues lost when using Attach method
I have the following Update generic method for my entities:
public void Update < T > (T entity) where T: class {
DbEntityEntry dbEntityEntry = DbContext.Entry(entity);
if (dbEntityEntry....
1
vote
2
answers
7k
views
view and download File from sql db using Entity FrameWork
Am new for hamdling Entity Framework.I use the following code for insert the file from fileupload button in mvc4
public ActionResult Index(NewUserModel newUser)
{
Resume ...
0
votes
1
answer
78
views
Conditionally save secondary table objects
I'm using the Entity Framework in my ASP MVC 3 site to handle a one-to-many relationship. The primary table (AgentTransmission) model object contains a List of secondary table objects (...
3
votes
2
answers
9k
views
Violation of PRIMARY KEY constraint. Cannot insert duplicate key
I'm using a List object to contain items from a secondary table that my primary table has a one-to-many relationship with. The PK of the primary table serves as the FK field on the secondary table.
...
0
votes
0
answers
183
views
LINQ deferred execution and returning null in left outer join
I've got two question, please see the following codes:
var table1 = from a in test1
join b in test2 on a.column1 equals b.column1 into jo
from jb in jo.DefaultIfEmpty()
...
0
votes
0
answers
15
views
EntityModel taking Nullable while creating a model
I have a query like
"
Select cast(0 as bit) as test1,1 as count
"
So when I try to create model for this SP using entity framework it's considering test1 as nullable. But I want it to be in not ...
1
vote
1
answer
1k
views
Storing Username to CreatedBy or UpdatedBy DB columns in Entity Framework 4.1
I am using MVC3, C#, Razor, EF4.1 (MS SQL2008 (dev) and SQL Azure (Test, Live)).
I would like to add a "CreatedBy" and "UpdatedBy" columns to certain tables and use the application "principal" ...
1
vote
4
answers
12k
views
Delete Many to Many relationship using Entity Framework
I've three tables Student (studID, fullName, gender...), Enroll (studID, courseID, date) and Course (courseID,courseName, ...). I used the code below to delete all records from Enroll table with ...
0
votes
0
answers
93
views
Primary Key, Foreign Key for Entity Framework class
For this class:
public class Movie {
public int MovieId { get; set; }
public string Title { get; set; }
public int Rating { get; set; }
public int ProducerID { get; set; }
public Producer ...
2
votes
2
answers
10k
views
entity framework sum and average without grouping
Is there a way in entity framework to get the following simple query
SQL Query
select avg(totalsalary), avg(totalhours) from context.employeedetails where company = 1234
In entity framework we are ...
0
votes
0
answers
159
views
Getting error while parent-child updating data in entity framework using linq
I'm having two table Client(ClientID,ClientName) and TIN(ClientTinID,Name,ClientID(foreign key)).One client can have multiple entries in TIN table.
I'm using EF database first approach for data ...
0
votes
1
answer
272
views
Linq quote returns no items if column of char(2) has default value of two spaces
I have a ProdFinSize table that has Range, Color, Model, Scale, Size, Rise, Inseam columns on it and the data type for the Inseam column is char(2) and has a default value of two spaces.
I wrote this ...
0
votes
0
answers
81
views
Mystified about bad performance of MVC3, EF4.1 against SQL Azure on a Cloud Service?
I have a web application which uses:
MVC3, Razor, C#, EF4.1, .NET4, MSSQL2008(local), SQL Azure(Cloud)
It reads data from DB, merges it and create an XHTML document.
When run locally(IIS Express/...
2
votes
2
answers
1k
views
Entity framework error as"New transaction is not allowed because there are other threads running in the session
We are using entity framework codefirst approach
I am new to entity framework and I am facing error while trying to do "New transaction is not allowed because there are other threads running in the ...
0
votes
1
answer
128
views
Issue with Jquery click event
I have implemented an application in MVC.I have created messagebox using jquery. when i clicked on button messagebox appears.
<button type="button" class="btn btn-primary" id="btnDispatch" >...
0
votes
1
answer
40
views
How can I re-create EF 4.1 EDMX models for EF 6 in VS 2010?
I am testing to migrate to EntityFramework 6 from 4.1.
I have some .EDMX models created by designer in VS 2010.
Question is: How can I re-create those EDMX models for EF 6? as I read that VS 2010 ...
0
votes
1
answer
173
views
Why does EF 4.1 code first returns a HashSet instead of a Collection
Getting this:
System.Collections.Generic.HashSet`1[Counter]
Expecting this:
ICollection<Counter>
//underlying Object:
public virtual ICollection<Counter> Counters { get; private set; }...
1
vote
0
answers
92
views
How can I use a 1-1 mapping on the same table in Entity Framework database first?
I have a situation where I have a contact, and a mapped contact. The mapped contact MAY exist, but it may be null.
This is a 0..1:1 mapping, so I've simply added a MappedContactId which has a FK ...
0
votes
1
answer
377
views
Child object is also getting saved
I am creating one to one relation ship using entity framework. I created two classes Student and IssueMaster. Both classes derived from base Entity class
public class Entity
{
public Entity()
...
0
votes
1
answer
61
views
How can I store the Web Application Username in a DB UpdatedBy or CreatedBy column?
I am using MVC3, C#, EF4.1 and SQL Server 2008.
I have a seperate Domain project for holding the POCO classes for interacting with the DB via EF.
I have implemented "UpdatedOn" using DB triggers. ...