Questions tagged [entity-framework-6.1]

1

votes
2

answer
40

Views

Having two classes representing the same table in Entity Framework?

I am trying to clean up some Entity Framework data contexts that were originally created without any naming conventions. I would like to keep the old classes but also have the new, properly named class available at the same time so that all the other projects that use these data contexts don't need...
John S
1

votes
2

answer
57

Views

Is there a way to automatically create CRUD for EF Model (DB First currently)

I am creating a WPF app and I have an existing DB that I would like to use and NOT recreate. I will if I have to, but I would rather not. The DB Is sqlite and when I add it to my data later and create a DataModel based on the DB, I get the model and the DB Context, however there are no methods creat...
Charlie
1

votes
1

answer
1.1k

Views

What's the correct way to use Effort with Entity Framework 6?

I'm trying to get some test code working using the Effort data provider with Entity Framework 6. What I'm trying to do seems like it should be the absolute simplest use-case, but I'm just not able to get things to work. Here is my DbContext class: public class CcdReductionFrameCatalogue : DbContex...
Tim Long
1

votes
1

answer
1.6k

Views

System.OutOfMemoryException Entity Framework 6 for db.SaveChanges

I'm running a batch job of inserting events into a database with entity framework. Total size varies but around 3.5 million events are normal. This list is split up into groups of 60-500k events that are then added to the database. However when around one million events have been added I get System....
Ogglas
1

votes
2

answer
75

Views

C# Entity Framework Adding to Many-To-Many Table

Is this a good practice to insert into a many-to-many table? user = new User { Id = userId, UserName = username, FirstName = firstName, LastName = lastName, UsersBooks = new List() }; book = new Book { Title = 'randomTitle2', Genre = 'randomGenre2', UsersBooks = new List() }; usersBooks = new UsersB...
Edwardcho Vaklinov
1

votes
1

answer
24

Views

SQL query to multiple objects using Entity Framework 6

I'm taking the time to learn EF (specifically version 6). I created two tables in MSSQL and linked up EF6 to the database creating the EF model framework. Then I created the classes in code. My desire is to have one row pulled with a list of items for 'UserDatas' (yes I know it's misspelled). Consi...
DaBlue
1

votes
0

answer
648

Views

EF how can I refresh Context with updated values in the Database?

I have a static Context that is doesn't refresh after updating values from the DB. Here is a little background on how the systems work. CRUD is done in a separate app. After saving to the DB triggers notify the API on the changes. After getting the changed Entity from the Context in the API, the en...
Ortho Home Defense
1

votes
1

answer
1.4k

Views

.NET Core 2.0 API with EF6 and .edmx file?

I want to build a API using .NET Core 2.0 that targets the full .NET framework so I can work with Entity Framework 6 and an .edmx file. Is this possible? How do I inject the DbContext generated by the .edmx file? I want to do this because my project works with a lot of stored procedures and I don't...
genzop
1

votes
1

answer
42

Views

Splitting EDMX Model

I'm looking to split my EDMX models into their own project to be referenced across the different projects without having to recreate the models across projects. I have one project that contains the Entity Data Model. I have another project that will contain common items across the projects. This com...
Tsukasa
1

votes
0

answer
56

Views

Data Annotation and EF6

I working on wpf application with syncfusion datagrid (SfDataGrid). The grid uses a data-annotation for autogenerated columns. The model is prepared by EF6. I'm trying to set a column header. This code works (header showing): public partial class ViewShortConsumer { [Display(Name = 'Heade...
Gennady Vorobev
1

votes
0

answer
198

Views

How to create a dynamic reporting platform using .net framework

I recently saw a reporting application in a small firm that would enable them to create and share reports very easily in few simple steps listed below: --Create a procedure in the database to get the relevant data for the new report. --Login to the reporting platform as an admin. --Choose your newly...
Aman Kumar
1

votes
0

answer
113

Views

Entity Framework detect changes before SaveChanges

I have a Web API that uses Entity Framework and an Angular SPA. I get an entity and pass it to the SPA, but then I get a DTO back from the SPA into my API. Now what is the best way to check to see if the data has changed by someone else? One possible scenario is to send the original entity along wit...
user1253073
1

votes
1

answer
95

Views

'System.Data.Entity.Database' does not contain a definition for 'ExecuteStoredProcedure'

I am using Entity Framework extras EF6 in Visual Studio 2013 for calling a stored procedure that takes table valued parameter. But on this line of code: context.Database.ExecuteStoredProcedure(procedure); I get this error: 'System.Data.Entity.Database' does not contain a definition for 'ExecuteStor...
Seema A
1

votes
0

answer
158

Views

Using custom MigrationOperation in CSharpMigrationCodeGenerator

I would like to create my own migration operations for the CSharpMigrationCodeGenerator, so I created my own migration operation derived from MigrationOperation. public class CustomMigrationOperation : MigrationOperation { public CustomMigrationOperation() : base(null) { IsDestructiveChange = false;...
Rod
1

votes
0

answer
51

Views

Entity Framework: One to many relationship using fluent API

I have two models (ApplicationStore, StoreAction) as shown below. I am trying to make one to many relationships i.e. ApplicationStore can have many StoreActions. I am using below fluent API syntax to make one to many relationship but getting error 'One or more validation errors were detected duri...
Haider Khalid
1

votes
0

answer
265

Views

Why does EF need VIEW SERVER STATE permission

We created new account (with all permissions granted - as we thought) in our database for web application (.NET MVC with Entity Framework 6.1.3) and an error appeared: SqlException: VIEW SERVER STATE permission was denied on object 'server', database 'master'. The user does not have permission to pe...
Adam Lihm
1

votes
0

answer
207

Views

Error when filtering on an Include in Entity Framework Core

I have the following EF Core linq statement: var contact = dataContext.Contacts .Include(c => c.Addresses) .ThenInclude(a => a.AddressType) .Where(c => c.ContactId == contactId) .Select(c => new Contact() { ContactId = c.ContactId, Title = c.Title, FirstName = c.FirstName, Surname = c.Surname, Addre...
Carl Rippon
1

votes
0

answer
179

Views

Entity Framework C# - DbGeometry POLYGON doesn't work

i have a problem with WKT and DbGeometry working together. When i use POINT as geometry like this example it works good. DbGeometry myGeometry1 = DbGeometry.FromText('POINT (30 10)'); DbGeometry myGeometry2 = DbGeometry.PointFromText('POINT (30 10)', 0); if i use POLYGON or any other geometry instea...
Digitarca Lab3
1

votes
0

answer
219

Views

Entity Framework 6 filtered index

I'm developing an application using Entity Framework 6 and I want to use filtered indexes (index with where clause). In Entity Framework there is an Index annotation which makes it possible to define an index on a property (column). I define something like public class SqlDefaultValueAttribute : Att...
hamed
1

votes
2

answer
320

Views

Entity Framework Connection error event

I'm trying to catch all SQLExceptions (connection error, timeout, etc) that EF might throw in a single place. I'm using a unit of work pattern with DI so there's no var using = context for example. Calls like .Single or .ToList are used all around the business logic. Is there any hook or event of cl...
E. Staal
1

votes
0

answer
216

Views

Add to odata collection property in .NET

Using the odata-v4 service connection in visual studio C# .NET, I get an entity of type testDefinition. testDefinition has property called features which is a collection of entities of type feature. In the DB, testDefinition to feature is many to many with a junction table. In my code, I add a servi...
Matt
1

votes
1

answer
79

Views

Many to Many Relation - Entity Framework

I'm working with a many to many relation, basically: +-------------+ +-----------------+ +---------------------------+ | Redes | | Objetivos | | RedesObjetivos | +-------------+ +-----------------+ +---------------------------+ | | RedesID | | | ObjetivosID | | | RedesID...
Caio Sant'Anna
1

votes
1

answer
35

Views

Entity Framework 6 partial primary key auto-incrementing

I am trying to make auto-increment key generation for only a part of the key for the given class: class MyEntity { [Key] public int OtherEntityId { get; set; } [Key] [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int MyEntityId { get; set; } [ForeignKey('OtherEntityId')] public virtual...
Artemoire
1

votes
2

answer
1.5k

Views

Entity Framework 6 mapping a custom SQL query to an Entity

I am very new to ASP.NET MVC and Entity Framework at the moment. I've been working with it for about 3 months at the current moment in time. I have an ASP.NET MVC 5 application that's running Entity Framework 6. This is a code first approach from an existing database with auto migrations enabled so...
Braden
1

votes
2

answer
165

Views

How to query data with calculated fields and map to a ViewModel with a nested ViewModel Collection?

I have referenced numerous questions on this site related to calculated fields and ViewModels, but I can't seem to extrapolate from examples given. I hope that laying out a specific scenario would allow someone to pin point what I can't see. I am new to WebApp design in general. Please take that...
Brad Rekkedal
1

votes
1

answer
33

Views

How to retrieve a tree of objects from a stored procedure?

I have a calculation that I'd like to do in a stored procedure, which includes some aggregations, to reduce the amount of data sent back to the caller. Given the structure: CREATE TABLE Parent ( ParentID int NOT NULL PRIMARY KEY, A1 int NOT NULL ) CREATE TABLE Child ( ChildID int NOT NULL PRIMARY KE...
Mike Dimmick
1

votes
1

answer
252

Views

EF6 database first for Oracle sometimes not generating a class for a table

I'm using Visual Studio 2013 and Entity Framework 6.1.3 against a legacy Oracle 12c database to generate a database first EDMX model. The problem I'm encountering is that for some tables, only a Storage Model definition of the table is generated, but it should be generating both a Storage Model def...
Bill at Work
1

votes
2

answer
231

Views

Entity Framework TPT - Insert sub-type for existing base-type

I am running into a problem where I want to insert a record for a sub-type with an existing record for the base-type. The base-type may be a Person entity described by: public class Person { [Key, Column('Id'), DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int Id { get; set; } public D...
rick
1

votes
1

answer
39

Views

Last Modified properties when using Entity Framework Extensions bulk methods

I'm trying out EFE for a large data syncing operation, and since it will involve either mass amounts of inserts or mass amounts of updates I've gone with the BulkMerge method. Our old way involved shoving everything into a giant complex data graph and then calling SaveChanges on our context. We hand...
Yoten
1

votes
1

answer
34

Views

Error Deleting a child object from its parent

I'm using vb.net 2013, Entity Framework 6 and SQL Server 2008 R2. I'm trying to delete from child entities, and this does not work. But if I try to delete directly from context, this works. In my database I have 2 tables Students and Result. This is my code that does not work : Dim context as Myenti...
Adriano
1

votes
0

answer
251

Views

EF 6 Error with NoTracking when navigating back and forth using the Proxy's Navigation Properties

In our EF 6 Code first application, we have issues with navigation properties in a non-tracking scenario. The requirements are: Entity must not be attached to the context and retrieved via NoTracking Proxy Generation must be enabled and Lazy Loading working You have to navigate to another Entity via...
Michael
1

votes
0

answer
366

Views

EF6 code first and VIEW

I would like to add a VIEW to the database, and query the data from this VIEW using L2E. I use migrations for maintaining database schema. I added one class that should MAP to a VIEW columns. As an example, this class has only two properties [Table('View_Data')] public class ViewData { [Key] public...
Goran
1

votes
1

answer
40

Views

delete single relation from many-to-many relationship ef6 c#

I'm trying to delete a single item (relation) from my many-to-many relationship but everything i've tried doesn't seem to work. This is my db: public class MyContext : DbContext { public IDbSet Playlists {get; set;} public IDbSet Songs {get; set;} //constructor protected override void OnModelCreati...
N. Calis
1

votes
0

answer
30

Views

Entity Framework many to many on the same table without duplicite records

I am trying to implement communication between user1 and user2. User1 can communicate with many users, also user2 can communicate with many users. I am trying to avoid having duplicate rows in intersect table (Chat). Example: user1 chatting with User2 is the same record as user2 chatting with user...
kostik
1

votes
0

answer
371

Views

Entity Framework 6 - An expression services limit has been reached

I have a question about EF. I have one DbSet like this: public class ToolsDbContext : DbContext { public DbSet ToolsObjects { get; set; } } And also have lots of inherited clasees from ToolsObject. When I inherited another two classes from ToolsObject I got this exception: System.Data.SqlClient.Sql...
MichalDawn
1

votes
1

answer
182

Views

EntityFramework6 / Npgsql: how to translate orderBy nulls last into SQL query

I am using EntityFramework6.Npgsql and am working with tables with several million records. Some of the entities have a timestamp / DateTime column which allows null values. Users often need to sort on this column and would like to show null values last in both asc and desc sorting. The column has t...
forrert
1

votes
1

answer
63

Views

Correct way to set up a 1 to Many So I can Query Attributes on the Included table with Entity Framework 6

I currently have a 2 table set up. I can include the Associated table with ease but I would like to be able to use a condition in the Where Clause and not sure where I need to change it. The relationship is a People can have Many Address public partial class People { public People() { Address =...
Joe Ricklefs
1

votes
1

answer
549

Views

Entity framework 6 dynamic connections string using DI

I have a unit of work with the repository pattern with simple injector implemented and I need to change my connection string dynamically. Currently the connection string is taken from the web config. I need the connection string be taken from the database. So I will have a database with the ASP.Net...
Wheels
1

votes
0

answer
184

Views

kendo grid 'Property' is not defined

Sorry for my English. I've got 'SCRIPT5009: 'Authors' is not defined' when I tried to add a new row to the grid. I tried to set a default value for property from my ViewBag but it doesn't work. May be someone already faced this error. Will be glad to any advice. The developer tools say that Authors...
Vlad
1

votes
1

answer
266

Views

Entity Framework: Query Multiple Types

I have a EF6 code-first model with inheritance, for example: [Table('Things')] abstract class AbstractThing { public int ThingId { get; set; } public string Color { get; set; } } class Car : AbstractThing { public string Brand { get; set; } } class Balloon : AbstractThing { public double Price { get...
Efrain

View additional questions