entity-framework-6

Entity Framework's 6's `ObjectQuery.EnablePlanCaching` - where is it?

夙愿已清 提交于 2019-12-25 08:14:31
问题 This article explains that query plan caching can be deactivated by setting EnablePlanCaching to false on the ObjectQuery , and also that it is enabled by default in EF6. Alas, EF6 doesn't have an ObjectQuery , the DbSet 's give you DbQuery s. I don't think I can get an ObjectQuery from the DbQuery , and I certainly don't want to use the old ObjectContext . So is that it or is there a way to disable plan caching in EF6? 回答1: Here is an extension method that will let you get an ObjectQuery

How to prevent or allow json serialization of a property from breeze controller

邮差的信 提交于 2019-12-25 07:16:27
问题 So it happens that you can prevent breeze json serialization of some properties using data annotations on your model by like this(well if you are using EF6 with JSON.NET on the backend)... [Table("Project")] public partial class Project { public Project() { } public int id { get; set; } [JsonIgnore] public bool NoLongerExist { get; set; } } By doing so the property becomes invisible on this endpoint used by breeze public IQueryable<Project> Projects() { return _db.Context.Projects.Where(o =>

How do I get my DataBase First EF 6.1 Entities to become a change tracking proxies

懵懂的女人 提交于 2019-12-25 06:48:39
问题 I'm struggling to get my model's entities to be change tracker proxies rather than utilize snap shot change detection. My entities are created by the EF designer and have been otherwise unmodified. I followed the steps in Programming Entity Framework: DbContext but my entities never seem to inherit the IEntitiyWithChangeTracker (though they are in fact DynamicProxies). Can anyone enumerate the steps to make an entity created by the DataBase First EF 6.1 designer into a change tracker proxy? I

Updating the Record with EntityState.Modified but its inserting the new row rather than update

只谈情不闲聊 提交于 2019-12-25 06:46:41
问题 I am using EF6 and in this i am trying to update the existing record in the database by using the EntityState.Modified state but its inserting the new row in the table rather tha updating it.I am using following code please let me know where i am going wrong. public Product UpdateProduct(ProductVM objProduct) { Product obj = new Product(); obj = JsonConvert.DeserializeObject<Product>(JsonConvert.SerializeObject(objProduct)); DbContext.Entry(obj).State = EntityState.Modified; DbContext

How to inject UserManager & SignInManager

强颜欢笑 提交于 2019-12-25 06:34:04
问题 I am trying to figure out how to inject UserManager and SignInManager. I have installed Ninject in my application and I am using it in the following manner: Please consider this to be a brand new project. Inside Startup.cs I have the following: public partial class Startup { public void Configuration(IAppBuilder app) { ConfigureAuth(app); app.UseNinjectMiddleware(CreateKernel); } private static IKernel CreateKernel() { var kernel = new StandardKernel(); kernel.Load(Assembly

Multi Database for Multi Tenant with Code first EF 6 and ASP.Net MVC 4

廉价感情. 提交于 2019-12-25 06:33:03
问题 I am building a SAAS application and planned for one database per client. I am using Code First EF6 with ASP.Net MVC 4. There will be 2 context i.e. MasterContext and TenantContext. User will first hit to MasterContext to authenticate user credentials and fetch its Tenant configuration. Based on fetched Tenant configuration; TenantContext is set to Tenant specific database and used for Tenant CRUD operations. Please advice how to achieve this. 回答1: The idea is to identify the current request

Add Primary Key of Linked Table to ASPNETUsers table Id field

我的梦境 提交于 2019-12-25 05:37:30
问题 I have successfully linked aspnetusers table to my custom users table as one-to-one relationship. Now when i go to register all information is successfully added to both tables except one thing - Id. My pk userId in users table is an AutoIncrement key and i wish to add the same value in the id field of aspnetUsers table. I think i will have to override createAsync or do i remove from SignInAsync await user.GenerateUserIdentityAsync(UserManager) Inside AccountController Register method, I have

Using WCF Data Services 5.6.0 with Entity Framework 6+

不羁的心 提交于 2019-12-25 05:01:16
问题 I have been trying to get our WCF Data Service to work with the new Entity Framework 6. I found this article which explains a supposedly easy and painless way to fix this issue. I followed the directions posted exactly. When I first install: Install-Package Microsoft.OData.EntityFrameworkProvider -Version 1.0.0-alpha1 -Pre I get the error: Error 16 The type 'Microsoft.OData.Service.DataService`1' is defined in an assembly that is not referenced. You must add a reference to assembly 'Microsoft

Entity Framework Code First Migration during deploy to production host does not work

喜你入骨 提交于 2019-12-25 04:43:35
问题 I am using VS2013 with Entity Framework 6.1 against SQL 2012. When I use Code First to create my classes and tables in Dev it works fine. When I go to publish via Web Deploy to my third party host everything deploys but none of the tables are created in the DB. The connection string/s contain the appropriate username and password for a user that has table create access to the DB. (Tested because I use the same login/password via SSMS to create tables on the hosted SQL server successfully) The

Entity Framework and inconsistent performance with processing the results of a query

混江龙づ霸主 提交于 2019-12-25 04:29:09
问题 Just setup New Relic on our site and we noticed some odd spikes in one of our webapi calls. At this point I have the problem boiled down to a single EF query that I moved out to its own method so I could use New Relic to instrument it.. The only thing the method does is //I changed this from ToListAsync to ToList to see if it would help var result = Context.Data.Where(x=> x.id = id).ToList(); return result; That's it.. Using New Relic and also logging out all the SQL queries I'm fairly