entity-framework

EF6 - Is there a way to clear EF cache / Local items without causing any change into the database?

霸气de小男生 提交于 2020-01-30 04:30:19
问题 Basically I am mixing EF with one call to a stored procedure which does some batch deletions, otherwise EF is too slow. Here is some pseudo-code of this scenario (I have more complex code in reality): public void RemoveCustomer(int customerUID) { // this code is running in one db transaction { // retrieve certain orders of particular customer using EF var orders = repoOrders.GetOrdersOfCustomer(filter, customerUID); // do something with above orders before deletion using EF repoX

MVC Drop Down list with entity framework

北城以北 提交于 2020-01-28 10:41:24
问题 I've created an MVC project using entity framework code first. My model is simply a form that gathers information. public class Application { public int Id { get; set; } public string FirstName { get; set; } public string MiddleInitial { get; set; } public string LastName { get; set; } public int SSN { get; set; } public DateTime DOB { get; set; } public string Street { get; set; } public string City { get; set; } public string State {get; set; } public string Zip { get; set; } public int

MVC Drop Down list with entity framework

旧巷老猫 提交于 2020-01-28 10:40:07
问题 I've created an MVC project using entity framework code first. My model is simply a form that gathers information. public class Application { public int Id { get; set; } public string FirstName { get; set; } public string MiddleInitial { get; set; } public string LastName { get; set; } public int SSN { get; set; } public DateTime DOB { get; set; } public string Street { get; set; } public string City { get; set; } public string State {get; set; } public string Zip { get; set; } public int

Auto Create Database Tables from Objects, Entity Framework

柔情痞子 提交于 2020-01-28 05:13:22
问题 I am trying to do this tutorial http://www.asp.net/mvc/tutorials/getting-started-with-aspnet-mvc3/getting-started-with-mvc3-part4-cs but instead of using the compact edition of SQL Server I am using a full install on my local machine. The way I read this tutorial is that the Entity Framework is suppose to create the tables from the objects I have defined. My problem is that I keep getting invalid object name dbo.movies, when I run the project. I finally got it to run by creating the table

keyword not supported data source

耗尽温柔 提交于 2020-01-26 15:13:32
问题 I have an asp.net-mvc application with the default membership database. I am accessing it by ADO.NET Entity Framework. Now I want to move it to IIS, but several problems showed up. I had to install SQL Server Management Studio, Create new DB, import there all the data from the previous .MDF file. Only thing left to do (as far a I know) is to change to connection string. However, I am not really experienced with this and keep getting the Keyword not supported: 'data source'. exception. Here is

ASP.NET MVC: Is Controller created for every request?

空扰寡人 提交于 2020-01-26 10:17:28
问题 Very simple question: Are controllers in ASP.NET created for every HTTP request, or are they created at application startup and reused throughout requests? Will the controller be created only for a particular HTTP request? If my previous assumptions are correct, can I depend on it? I want to create database context (Entity Framework) that will live only for one request. If I create it as a property initialized in controller's constructor, is it granted that new instance of context will be

ASP.NET MVC: Is Controller created for every request?

狂风中的少年 提交于 2020-01-26 10:17:26
问题 Very simple question: Are controllers in ASP.NET created for every HTTP request, or are they created at application startup and reused throughout requests? Will the controller be created only for a particular HTTP request? If my previous assumptions are correct, can I depend on it? I want to create database context (Entity Framework) that will live only for one request. If I create it as a property initialized in controller's constructor, is it granted that new instance of context will be

Implementing Zero Or One to Zero Or One relationship in EF Code first by Fluent API

别来无恙 提交于 2020-01-26 08:46:35
问题 I have two POCO classes public class Order { int id; string code; int? quotationId; //it is foreign key public int Id{get;set;} public string Code{get;set;} public int? QuotationId{get;set;} Quotation quotation; public virtual Quotation Quotation { get; set; } .... } public class Quotation { int Id; string Code; public int Id{get;set;} public string Code{get;set;} Order order; public virtual Order Order { get; set; } .... } each Order may made from one or zero quotation, and each quotation

Implementing Zero Or One to Zero Or One relationship in EF Code first by Fluent API

青春壹個敷衍的年華 提交于 2020-01-26 08:46:07
问题 I have two POCO classes public class Order { int id; string code; int? quotationId; //it is foreign key public int Id{get;set;} public string Code{get;set;} public int? QuotationId{get;set;} Quotation quotation; public virtual Quotation Quotation { get; set; } .... } public class Quotation { int Id; string Code; public int Id{get;set;} public string Code{get;set;} Order order; public virtual Order Order { get; set; } .... } each Order may made from one or zero quotation, and each quotation

Entity Framework generated really bad SQL when using ANY

妖精的绣舞 提交于 2020-01-26 04:00:07
问题 I'm analyzing the queries that are running in a DB (Azure Sql Server V12) and I found a few queries generated by Entity Framework (EF 6.0) that make no sense to me. They are really bad for performance and I cannot find where they are generated. (@p__linq__0 nvarchar(4000))SELECT CASE WHEN ( EXISTS (SELECT 1 AS [C1] FROM [dbo].[SellerPhone] AS [Extent1] WHERE [Extent1].[Phone] = @p__linq__0 )) THEN cast(1 as bit) WHEN ( NOT EXISTS (SELECT 1 AS [C1] FROM [dbo].[SellerPhone] AS [Extent2] WHERE