Tagged Questions
The ADO.NET Entity Framework Version 6.
0
votes
0answers
8 views
0
votes
0answers
3 views
Entity Framework ExecuteSqlCommand does not recognize last parameter
I have an update procedure with 27 parameters. I have a Patient Entity that I populate and send to the UpdatePatient method in the repository. When I call the ExecuteSQLCommand it throws the ...
0
votes
0answers
11 views
ASP.MVC Code First EF6. Relations between entities in defferent dbcontexts
The question is: "Can relationship be created between two different dbcontext classes?"
For example. Can I create relation beetwen ApplicationUser class from IdentityDbContext and Foo class from ...
0
votes
0answers
6 views
Issue in mapping fragments using Entity Framework 6 (EF6)
I am getting the following error while trying to create my data class:
(1063,10) : error 3004: Problem in mapping fragments starting at line 1063:No mapping specified for properties ...
0
votes
1answer
16 views
Prevent EF from adding new child objects instead of just association when inserting new parent object?
I have the following:
public int CreateExercise(Exercise newExercise) {
db.Exercises.Add(newExercise);
db.SaveChanges();
return newExercise.ExerciseId;
}
Where ...
0
votes
0answers
20 views
what is better multiple tables or one table with full text search
I'd like to use full text search in entity framework 6 with table valued functions (I think TVF is the correct way to use full text search in EF6 but haven't implemented it yet?) in a MVC application ...
0
votes
1answer
28 views
MVC5: UserManager.AddToRole(): “Error Adding User to Role: UserId not found”?
I have been experimenting with MVC5/EF6 and trying out the new Identity Authentication with Code-First Migrations. Everything in the solution is currently building and I can add a Migration, but when ...
0
votes
0answers
34 views
How to create a custom DbSet
How to create a custom DbSet to be used in our context,
here I ferived from DbSet which the code sample is provided below.
In the Context I have:
public CustomDbSet<Items> MyDbSet { get; set; ...
2
votes
2answers
61 views
EF sorting & paging - slow as ordered twice?
I have a simple entity, and I have 100,000 of them in my SQL Sever 2012 database:
public class Entity
{
public int Id { get; set; }
public string Field1 { get; set; }
public string Field2 ...
0
votes
0answers
17 views
How to create custom additional fields in UserProfile in MVC4 & EF6
I'm trying to add custom user fields in my application (first name, last name, etc.). I used this, but getting errors. In a comment under the entry, I conclude that I have a newer version of EF. Does ...
1
vote
0answers
23 views
How to associate DBSets when moqing the whole Context?
Using the EntityFramework.Testing.Moq repository provided by Rowan Miller. I'm trying to mock an entire EF6 Context, including mock instances of all the DBSet's.
Data for each DBSet is loaded from an ...
0
votes
1answer
22 views
Two properties of same type mapping to a single table which has a column to distinguish the target property
I have two tables:
parents
id
childs
parent_id
child_number
and two corresponding entity-types where i want the type Parent to have two navigation properties linking to the first and second ...
0
votes
1answer
12 views
SimpleMembership seed configuration troubles
I am trying to set up simplemembership for ASP.NET MVC4 application
I try to seed configuration, I was able to create Roles but not users I get an error saying
You must call the ...
0
votes
1answer
21 views
Entity Framework 6 Code First - Required Enum data type not working
I am generating a database table using an required enum field.
However, when feeding the table, it is possible to omit to feed the enum field: EF will not throw any error message but will feed the ...
0
votes
2answers
25 views
Does reusing a DB connection with EF 6 DbContexts save time?
My code is littered with using blocks that instantiate, use, and dispose a DbContext object. Would it improve performance any if I passed an open connection to the constructors of these objects, or ...
1
vote
0answers
20 views
Trying to using EF 6 with PostgreSQL - Failed to find or load the registered .Net Framework Data Provider
I am trying to use EF 6 Code First with Npgsql provider. When I try to run Add-Migration command in package manager I have the following exception: Failed to find or load the registered .Net Framework ...
0
votes
0answers
13 views
How to configure EntityFramework 6 in web.config file?
I am having error when I try to connect to remote database using EF6
I am trying to connect to remote MySQL DB using EF6
What changes do I need to make in my web.config for EF6 to work with MySQL in ...
0
votes
1answer
12 views
Entityframework model first decimal precision
I'm using Entityframework 6 with model first. In the diagram I have chosen decimal for my datatype. When I save decimal values, the database only has whole numbers and the decimals get dropped.
My ...
0
votes
0answers
16 views
EF6 Concurrency with inherited types and sqlserverce
I am trying to get concurrency checking working with EF6, code first. First of all I added
RowVersion with [Timestamp] attribute to my class. This gave an error because the class was inherited. I then ...
0
votes
1answer
5 views
Several identical many-to-many relationships with attributes with one entity class for each of the linking tables
I have an Email entity which has To, Cc, and Bcc collections of Contact entities. The relationships are many-to-many and I need ordering for the emails in To, Cc and Bcc. So I have to introduce a 3rd ...
0
votes
1answer
15 views
EF Reverse POCO Generator: Failed to load provider EntityClient
I'm using
EntityFramework Reverse POCO Generator in VS2012
VS2012...
Here's my connection string:
<connectionStrings>
<add name="Entities" ...
2
votes
1answer
29 views
EF6: How to ignore nested enums from mapping
EF 6 Code First. I have several reference entities with nested enums for convenience. For example:
public class StatusA
{
public enum Values
{
Active = 1,
Inactive = 2,
...
0
votes
1answer
17 views
Nuget Package supporting multiple versions of their dependency
I'm looking for some experience or thoughts on the following problem.
I have a Nuget Package (EntityFrameworkExtras 1.2.0) thats hosted on the main Nuget Feed.
This package has a dependency on ...
0
votes
1answer
19 views
Entity Framework map multiple columns to C# complex type
I have a table where I use four columns as the primary key: Major, Minor, MajorRevision, MinorRevision.
I'm using Entity Framework 6.1 Code-First lazy loading, can someone give me an example of how I ...
0
votes
0answers
15 views
EF - Access derived types from context
Here's an example of my issue. Here are my EF classes...
public class basetype{
}
public class derived : basetype{
}
Is there any way to directly access derived entities from the database context ...
0
votes
1answer
49 views
Breeze.js with ASP MVC5 and AngularJS
I'm looking into creating an ASP MVC5 project (NOT an WebApi, I have to stick with ASP.MVC) with Breeze.js and AngularJS but I'm facing all kind of problems as the documentation is not complete on ...
0
votes
1answer
39 views
Selecting many columns/fields with lookup and junction tables. Out of memory exception
I have a real estate database that is highly normalized for storing listing data. The primary data is spread between 3 tables (Listings, ListingDataCommons and ListingDataOthers) because of the ...
2
votes
3answers
44 views
LINQ to Entities does not recognize the method IsNullOrWhiteSpace
I have the below code:
var countries = from c in db.Countries
where (string.IsNullOrWhiteSpace(searchAlpha2) || (c.Alpha2 ?? string.Empty).ToUpper().Contains(searchAlpha2.ToUpper()))
...
1
vote
2answers
33 views
Adding ADO.Net Entity Data Model using machine.config connection string
I am at the beginner level of learning MVC5 using EF6. Basically I am trying to use a connection string defined in machine.config rather than using web.config whilst creating the ADO.NET Entity Data ...
0
votes
1answer
10 views
Call custom function in EF LINQ query Where clause
Env: EF6 + Code First
I want to be able to call a custom function in the Where clause of a LINQ query
So this line:
var activeStaff = Repo.Staff.Where(s => s.EndDate == null || s.EndDate.Value ...
0
votes
0answers
16 views
How to order by and/or have where conditons on xmlcolumn using entity framework 6
Using entity framework, I am building a possibly complex query where I'd like to be able to query and sort on various columns, including the XML column, and in which the columns are not known in ...
1
vote
1answer
43 views
MVC5/EF6: Object cannot be deleted because it was not found in the ObjectStateManager?
I have the following HttpPost Delete() method which was working in my MVC5 app. To the best of my knowledge nothing relating to this controller, the View, or even the model has changed.
// POST: ...
0
votes
0answers
28 views
Entity Framework keyword search map to multiple tables
I want to make a keyword search in my product database. My current database is structured like this:
- Catetory
-- SubCategory
--- Products
The idea is to make a Keyword and KeyworkRef table, so ...
0
votes
1answer
9 views
Entity Framework foriegn key to existing table column
I have the following table in my database
Company
resourceId (uniqueidentifier)
name (nvarchar(50))
I have the following User entity in my application
public class ApplicationUser : ...
0
votes
1answer
34 views
Handle/Prevent NullReferenceException in MVC5 View? [duplicate]
I have a View which is using Grid.MVC to display desired User Properties. My controller below, uses the User [MemberOrgID] or [SponsorOrgID] to find the all the relevant Org/Sponsor information ...
0
votes
2answers
26 views
IDENTITY_INSERT during seeding with EntityFramework 6 Code-First
I have an entity that has an Auto-identity (int) column. As part of the data-seed I want to use specific identifier values for the "standard data" in my system, after that I want to have the database ...
0
votes
2answers
26 views
Entity Framework Code First Don't Create Table
I'm using an existing database and I have mapped one of the tables as an entity (as i needed to map a foreign key).
So when it comes to initialising this database I would like EF to ignore this ...
0
votes
1answer
33 views
Entity Framework create a foreign key by referencing primary key of the same table
I want to use Entity Framework code-first to create a foreign key by referencing primary key of the same table. Please run the SQL to understand the requirement, though let me best put it up.
I have ...
0
votes
0answers
17 views
NHibernate Envers like Audit Log with Entity Framework 6+
NHibernate Envers does a good job of creating an Audit Log whenever an entity is Updated/Deleted. Basically it creates an Audit table for each auditable entity and write a snapshot of the data into ...
0
votes
1answer
17 views
Naming foreign key column
I defined those 2 tables:
[Table("languages")]
public class Language
{
[Key]
[Column("language_id")]
public int LCID { get; set; }
[Column("title")]
public string Title { get; ...
0
votes
1answer
18 views
Entity Framework 6: Associating a 'Child' Collection
Let's say I have a table that looks like so:
Person
{
int Id,
string Name,
int? ParentId
}
In entity framework, I can add a new property Person Parent and I can tell entity framework how ...
0
votes
0answers
16 views
MVC5/EF6: Store Table2 String Value into Table1 virtual property?
I have a View where I am rendering my various Identity User properties in a Grid for Admin actions:
@using GridMvc.Html
@model IEnumerable<PROJECTS.Models.ApplicationUser>
@{
ViewBag.Title ...
1
vote
2answers
40 views
Prefixing table names causes discriminator column to be removed
I have a lookup table that is fairly simple
public class LookupType : Entity
{
public LookupType()
{
}
public LookupType(string value)
{
Value = value;
}
public ...
1
vote
1answer
47 views
What is the difference between ExecuteSqlCommand vs SqlQuery ? when doing a db access?
I have had a couple of suggestions on how to access data from my database:
var allMyIds
= context.Database.ExecuteSqlCommand("select id from AspNetUserLogins");
var allMyIds
= ...
2
votes
2answers
46 views
Will using Entity Framework in ASP.NET MVC allow my web project to work on different database vendors
I have been using asp.net MVC web application and Entity Framework with SQL Server 2008 R2. But now one of our clients requires us to use Oracle 10g database. So my question is what will happen if I ...
1
vote
2answers
38 views
Navigation property incompletely loaded after eager load
lI use a code looking like this one to select a large list of objects, for read only purpose :
using (DBContext db = new MyContextClass())
{
... data creation ...
db.SaveChanges();
}
using ...
1
vote
1answer
39 views
No Entity Framework provider found for the ADO.NET provider
I've been trying to insert some data into northwind using WCF. I can't figure out why the provider isn't found.
The service has EF6 installed.
Here's the snippet of my config file:
<?xml ...
0
votes
2answers
113 views
+500
Query Xml from SQL using Entity Framework Database First
I need to use Entity Framework, LINQ to query the XML data from the SQL in my asp.net mvc(C#) application.
I have a column XMLValue with data
<MetaData>
<Reviews>1</Reviews>
...
0
votes
0answers
18 views
Entity Framework for Storage only?
With my limited knowledge of Entity Framework, I'd like to know if it's at all common to use Entity Framework for Storage of data only, and rather use custom built stored procedures to get complex ...
0
votes
1answer
13 views
In this by-CodeFirst-EF-generated schema, lazy loading is working only on 2 of the 3 properties. Isn't that inconsistent?
SOLUTION:
To make lazy loading work i had to do a few things:
make sure EF could override my Models:
make the navigation properties (basically every property that has one of my models as a type) ...