entity-framework-6.1 Questions

5

Solved

In my application I enable Code First Migrations with some migrations, Also I use SQL Server Compact for integration test. When I run my tests, Entity Framework create an empty database and tries ...

6

Solved

I have a test class and an ExecutionDate property which stores only date but when we use [DataType(DataType.Date)] that also stores the time portion in database but I want only date portion. publi...

4

Solved

I am trying to do a simple update to the foreign key but the script never get sent over. Here is the code I am using: using (var db = new MyContext()) { db.Entry<Contact>(newContact).State...

4

I would like to be able to iterate through every row in an entity table without holding every row in memory. This is a read only operation and every row can be discarded after being processed. If...

2

I'm attempting to simulate a scenario in which I am inheriting from concrete base classes in a 3rd party library, then mapping my own classes using Entity Framework Code First. I would really prefe...

3

Solved

I implemented the soft-delete pattern demonstrated by Rowan Miller during a TechEd session but I ran into an immediate problem because I am using inheritance in my Code First model. The first error...
Decompress asked 22/7, 2014 at 16:25

2

Solved

Today is a sad day. First thing today I saw EF exception saying that "The model backing the 'DomainContext' context has changed since the database was created.". It is close to midnight and I still...
Bandog asked 25/3, 2014 at 23:57

2

Solved

Well, the question is clear enough. Is it possible to create spatial indexes using Entity Framework 6.1 fluent API?

2

Solved

Example: Let's say I have these three classes. Foo is a proper Entity Framework entity with a DbSet whereas I want my EF DbContext to be unaware of Bar and Baz because I have flagged Foo's Bar prop...

1

I'm having some difficulty getting my two contexts that use the same database to cooperate. Here's the scenario: In an MVC application using EF 6 Code-First, there is one database with two contex...

2

Solved

I saw a post today about implementing SqlAzureExecutionStrategy: http://romiller.com/tag/sqlazureexecutionstrategy/ However, all examples I can find of this use a Configuration that inherits from...

1

I want to reduce startup time in EF6 by caching the DbCompiledModel to disk. It's easy to write the EDMX file for a DbContext: EdmxWriter.WriteEdmx(myDbContext, XmlWriter.Create(@"C:\temp\blah.xm...

1

Solved

Why do I get an DbUpdateException - there are no further details - when I try to insert a new pupil to an existing schoolclassCode? This is a many to many relation. var schoolclassCode = await co...
Homogenous asked 24/6, 2015 at 12:52

1

Solved

I am looking for a quick way to clean my tables data doing integration tests with EF. Everyone seems to wrap a transaction around its test method and dispose the transaction after the test. That ...
Emanuel asked 12/6, 2015 at 23:26

0

I an using EF6 database first design in a web application. There is one entity that is involved in two 1-to-many relationships (the E2 in this example): E1 <--- E2 ---> E3 E1 and E3 both have a...
Ocko asked 14/5, 2015 at 21:19

1

Solved

I'm trying to use an Entity Framework CommandTree interceptor to add a filter to every query via a DbContext. For the sake of simplicity, I have two tables, one called "User" with two columns ("Us...

1

Solved

I would like to prevent this from happening but in a different way rather than setting type of DateCreated to nullable DateTime. The full exception reads like this: The cast to value type 'Syst...
Subaxillary asked 24/3, 2015 at 2:25

1

Solved

What is the diff between these two statements? Both should delete an entity. _context.Entry(new Schoolyear { Id = schoolyearId }).State = EntityState.Deleted; _context.Schoolyears.Remove(new Sc...
Prussia asked 7/3, 2015 at 8:13

1

Using EF 6.1, I want to set a foreign key to null (break the relation between two entities), without querying for either object first. Preferably, I also don't want to supply the id of the related ...
Nailbiting asked 23/1, 2015 at 9:28

1

Solved

I have a very simple EF operation that fails: break the relationship between two entities as shown in the code below: public async Task RemoveCurrentTeacherOfGroup(int groupId) { var group = awai...
Aqua asked 22/1, 2015 at 16:22

1

Solved

In Entity Framework 6.1, in a C# code-based migration (using System.Data.Entity.Migrations.DbMigration), when altering a stored procedure definition using the DbMigration.AlterStoredProcedure metho...
Zebec asked 29/12, 2014 at 22:5

3

I am working with a situation where we are dealing with money transactions. For example, I have a table of users wallets, with their balance in that row. UserId; Wallet Id; Balance Now in our w...

1

I understand how to add conventions to the code first (with migrations) project. I have successfully managed to perform the table names and even changed GUID Id fields to non-clustered. But I have...

1

Solved

I'm using EF 6.1.1 and Database First. When I import a stored proc into the edmx and generate the DBContext it looks like this: return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction&l...

1

Solved

I Have defined an entity class with a key, but I don,t want that key be cluster because I have another cluster index in my entity, but I received an error when I add an Index attribute to my model,...

© 2022 - 2024 — McMap. All rights reserved.