entity-framework-6

WCF Data Services Entity Framework

╄→гoц情女王★ 提交于 2019-12-24 05:32:05
问题 I came across this question in Stackoverflow (because I am getting the same exception) Upgraded to EF 6 (RTM) - Getting System.Data.Entity.Core.Objects.ObjectContext cannot be used for return type System.Data.Objects How can I use the WCF Data Services Entity Framework Provider? I cannot find that Nuget package. Was it removed? Am I doing something wrong? 回答1: Dumb question sorry this is the reason: 来源: https://stackoverflow.com/questions/32191112/wcf-data-services-entity-framework

WCF Data Services Entity Framework

邮差的信 提交于 2019-12-24 05:31:10
问题 I came across this question in Stackoverflow (because I am getting the same exception) Upgraded to EF 6 (RTM) - Getting System.Data.Entity.Core.Objects.ObjectContext cannot be used for return type System.Data.Objects How can I use the WCF Data Services Entity Framework Provider? I cannot find that Nuget package. Was it removed? Am I doing something wrong? 回答1: Dumb question sorry this is the reason: 来源: https://stackoverflow.com/questions/32191112/wcf-data-services-entity-framework

Two tables referencing each other in Entity Framework 6 Code First

此生再无相见时 提交于 2019-12-24 05:20:10
问题 I have the entities Project and Sprint where a Sprint belongs to a Project. A Project also contains a Backlog which is a reference to a single Sprint it will add items to by default. public class Project { public long ID { get; set; } public string Name { get; set; } public long BacklogId { get; set; } public Sprint Backlog { get; set; } } public class Sprint { public long ID { get; set; } public string Name { get; set; } public long ProjectId { get; set; } public Project Project { get; set;

Code-first, setting database collation

[亡魂溺海] 提交于 2019-12-24 04:51:33
问题 Is there any way to configure what collation to use when EF creates the database? Or is there some kind of hook to set the collation after the database is created but before the tables are created? Entity Framework 6.1.1 MS SQL 2012 回答1: I solved the issue by creating the DB myself. The base class is then creating the tables into the empty DB: public class MyInitializer : CreateDatabaseIfNotExists<MasterDataModel> { public override void InitializeDatabase(MasterDataModel context) { if(

Lost migrations and Azure database is now out of sync

流过昼夜 提交于 2019-12-24 04:02:15
问题 The quick question is "How do I get my Azure database back in sync with my local database?" Details: I have been using entity framework in my project, which really not that different from the ASP.NET MVC 5 sample project, which has Identity 2 built in. There are two database contexts, one called ApplicationDbContext (aspnet_somethingUserDB) from Identity and the other one called StoreInitialTestContext (store_db) that is from my changes. Interestingly, I have each of these contexts in a

UserManager.Create: An exception of type 'System.MissingMethodException' occurred in mscorlib.dll but was not handled in user code

落花浮王杯 提交于 2019-12-24 03:43:29
问题 I am currently building a website in Visual Studio Express 2013 for Web, and I am using the default membership functionality for users to register. However, when I open the website on localhost and attempt to register a user, I receive the following error: An exception of type 'System.MissingMethodException' occurred in mscorlib.dll but was not handled in user code Additional information: Method not found: 'System.Threading.Tasks.Task`1<!!0> System.Data.Entity.QueryableExtensions

How can I cast a string to a decimal using a custom DbFunction

℡╲_俬逩灬. 提交于 2019-12-24 03:25:06
问题 I have a table with decimals (and other types) saved as strings. I want to write a Linq query on the database context that will translate to a database cast and not a local cast (for performance reasons). This non-working example is conceptually what I want to achieve. using ( var context = new MyContext() ) { return context.SomeTable .Select(o => new { o.Id, (decimal)o.SomeString }); } This is a bad way to achieve it since it will run the conversion on the application side. using ( var

How to monitor transaction isolation level changes in SQL Profiler or in any other tool

ⅰ亾dé卋堺 提交于 2019-12-24 03:10:33
问题 I've successfully only been able to see transaction isolation level events in the Audio Login event. Are there any other ways to monitor the transaction isolation level changes using SQL Profiler or using some other tool? The reason I ask is because SQL Profiler does not seem to be able to output the events in the right order or it skips events because when setting the IsolationLevel to Serializable in my app it still shows transaction isolation level read committed . Example Audit Login in

Incorrect SQL generation on query

丶灬走出姿态 提交于 2019-12-24 01:13:23
问题 Dim records = From record In db.table Where record.Level = "Level 1" Where record.NewNumber IsNot Nothing Select record.Number When I call records.ToString() I get an output like so: SELECT [Extent1].[Number] AS [Number] FROM [dbo].[table] AS [Extent1] WHERE [Extent1].[Level] = @p__linq__0 The where clause for NewNumber is not null is missing. If I change the linq to where NewNumber is nothing I get the following: SELECT CAST(NULL AS varchar(1)) AS [C1] FROM ( SELECT 1 AS X ) AS

More efficient way to perform a UPSERT with EF6

隐身守侯 提交于 2019-12-24 00:39:33
问题 I have the following code block that basically checks for the existance of a entity in the DB and loads it to context for updating or in case it does not exist adds the new entity. using (var db = new Entities.DB.DConn()) { //... foreach (Account account in accounts) { bool isNewRecord = false; Entities.DB.Account dlAccount = new Entities.DB.Account(); Entities.DB.Account exisitngAcct = db.Accounts.Where(x => x.GId == dlG.Id).FirstOrDefault(); //x.GId is NOT ad primary key if (exisitngAcct !=