entity-framework-6

Column names in each table must be unique. Column name 'StripeRecipientId' in table 'dbo.Foos' is specified more than once

断了今生、忘了曾经 提交于 2019-12-22 04:05:36
问题 I have a model class named Foo that has, among others, these properties. public string StripeRecipientId { get; set; } public override bool HasProvidedBillingInformation { get { // return !string.IsNullOrEmpty(this.StripeRecipientId); return false; } } I have enabled migrations and am using Code First. When I run the update-database commandlet, whether with -Force option is specified or not, I get this error: Column names in each table must be unique. Column name 'StripeRecipientId' in table

What logic determines the insert order of Entity Framework 6

女生的网名这么多〃 提交于 2019-12-22 03:24:29
问题 So, I have a DBContext, and I am doing the following operations: dbContext.SomeTables1.Add(object1) dbContext.SomeTables2.AddRange(objectArray2) dbContext.SomeTables3.AddRange(objectArray3) dbContext.SaveChanges(); The EF doesn't insert the db records in this order, it inserts them in a random order. To insert them in the same order, I have to do a dbContext.SaveChanges() after each addition. This is not an efficient solution and in my case, it is taking 10 seconds to do all my inserts, while

How does the SQLite Entity Framework 6 provider handle Guids?

拥有回忆 提交于 2019-12-22 02:27:10
问题 I am porting our product's database to SQLite from another product that supported Guids. As we know, SQLite does not support Guids. I've got created an entity framework 6 model from my database (database first) and I need to build a query from C# that compares the Guid to one passed from the code. The thing is I can't find any documentation on how the SQLite Entity Framework provider handles Guids. A web search didn't find anything useful for me, either. Just questions about using Entity

How to setup EF6 Migrations with ASP.NET Core

心不动则不痛 提交于 2019-12-22 01:49:21
问题 I am trying to adopt Jimmy Bogard's ContosoUniversityCore project I would like to do code first migrations, but not sure how to properly set it up. I added Migrator.EF6.Tools to my project. When I run Enable-Migrations I get this error: Exception calling "SetData" with "2" argument(s): "Type 'Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.Automation.OAProject' in assembly 'Microsoft.VisualStudio.ProjectSystem.VS.Implementation, Version=14.1.0.0, Culture=neutral, PublicKeyToken

Configure EF to not drop any tables in migration

吃可爱长大的小学妹 提交于 2019-12-21 23:24:16
问题 I am using EF migrations to dynamically create a database model at run-time. This can happen many times, sometimes modifying existing tables and sometimes not. As every time i do a migration I don't want to create a massive context containing all the DbSets on the whole database I just want to include the tables I'm currently modifying. I am doing the migration in the following way Type contextType = null; //This will be my dbcontext DbMigrationsConfiguration migratorConfig = new

Failed to save data using EF6. Error: OriginalValues cannot be used for entities in the Added state

本秂侑毒 提交于 2019-12-21 20:22:09
问题 I am quite new to entity framework. As a starter to understand more about EF, I am trying to make a generic implementation of EF6 following example of http://genericunitofworkandrepositories.codeplex.com/ . I was able to save data using same entity while tried plain and simple implementation when I started creating the project. But, now i got error while I tried to save data. The Error: OriginalValues '(($ReturnValue1)).OriginalValues' threw an exception of type 'System

Why does Azure Database perform better with transactions

只愿长相守 提交于 2019-12-21 09:37:38
问题 We decided to use a micro-orm against an Azure Database. As our business only needs "inserts" and "selects", we decided to suppress all code-managed SqlTransaction (no concurrency issues on data). Then, we noticed that our instance of Azure Database responded very slowly. The " rpc completed " event occured in delays that are hundreds times the time needed to run a simple sql statement. Next, we benchmarked our code with EF6 and we saw that the server responded very quickly. As EF6 implements

Why does Azure Database perform better with transactions

谁说胖子不能爱 提交于 2019-12-21 09:36:04
问题 We decided to use a micro-orm against an Azure Database. As our business only needs "inserts" and "selects", we decided to suppress all code-managed SqlTransaction (no concurrency issues on data). Then, we noticed that our instance of Azure Database responded very slowly. The " rpc completed " event occured in delays that are hundreds times the time needed to run a simple sql statement. Next, we benchmarked our code with EF6 and we saw that the server responded very quickly. As EF6 implements

Combine Code First & Database First In Single Model?

眉间皱痕 提交于 2019-12-21 09:34:13
问题 Is there a way to combine code-first and database-first in the same context? We are running into massive development-time performance problems when editing the EDMX file (it takes 1.5 minutes to save). I've moved our non-insert/update/delete UDFs/stored procs to some custom T4 templates that automatically generate model-first code, but I can't seem to get OnModelCreating to be called when EDMX is involved. Other things we've considered, but won't work for one reason or another: We can't

Combine Code First & Database First In Single Model?

╄→гoц情女王★ 提交于 2019-12-21 09:34:05
问题 Is there a way to combine code-first and database-first in the same context? We are running into massive development-time performance problems when editing the EDMX file (it takes 1.5 minutes to save). I've moved our non-insert/update/delete UDFs/stored procs to some custom T4 templates that automatically generate model-first code, but I can't seem to get OnModelCreating to be called when EDMX is involved. Other things we've considered, but won't work for one reason or another: We can't