entity-framework-6

How to disable Migration Verification during every DbContext initialization

我是研究僧i 提交于 2019-12-24 09:06:50
问题 I am using CodeFirst approach in Entity Framework 6 and running my migration script manually to create Db and later update the changes in the schema. I have noticed that every time the context is initialized , it checks for the " INFORMATION_SCHEMA.TABLES " and " MigrationHistory " metadata in the database. That adds 2 additional queries for each call . This may not be a desirable situation for production environment. Is there a way to set it only once during application startup and these 2

Entity Framework include children that grand children are null

不打扰是莪最后的温柔 提交于 2019-12-24 08:39:09
问题 Seem like a simple one, but not coming up with the right thing. All that I need to do is get a count of child items that have it's own child null. Here is what I have been working with: var data = await _context.award.Include(a => a.expenses.Select(p => p.invoice == null)).ToListAsync(); I have also tried other combinations here with no luck. The error I get is InvalidOperationException: The property expression 'a => {from expense p in [a].expenses select ([p].invoice == null)}' is not valid.

EF6 Foreign key with one-to-one relationship and two-way property navigation

梦想与她 提交于 2019-12-24 08:07:12
问题 I cannot seem to get EF6 to generate a FK when I am using two-way navigation. Here are my classes (removed some properties for brevity): public class BaseSystem { public int Id { get; set; } public SystemConfiguration Configuration { get; set; } } public class SystemConfiguration { public int Id { get; set; } public BaseSystem System { get; set; } } I want the SystemConfiguration table to have a FK reference back to BaseSystem.Id . Here's my fluent API code: modelBuilder.Entity

OData Patch is not updating the database

£可爱£侵袭症+ 提交于 2019-12-24 07:37:52
问题 I have a WebApi 2 controller. I want to use OData Patch on one of the controllers. Here's what I did so far. I added the following line in WebApiConfig config.MapODataServiceRoute("odata", "odata", GenerateEdmModle()); private static Microsoft.OData.Edm.IEdmModel GenerateEdmModle() { var builder = new ODataConventionModelBuilder(); builder.EntitySet<Auth>("Auths"); return builder.GetEdmModel(); } Then in the controller, This is how I'm trying to use patch method [HttpPatch] public async Task

System.StackOverflowException from a simple EF6 query

风流意气都作罢 提交于 2019-12-24 07:32:30
问题 I created a project that references a class library data layer project. The data layer is generated in Visual Studio using Code First from database : Add New Item => ADO.NET Entity Data Model => Code First from database I have selected all tables from a huge database (~1000 tables) and at the moment when I try to get something from any of the tables, it just hangs and eventually throws System.StackOverflowException . The query looks like that: using (var context = new MyDbModel()) { var test

System.StackOverflowException from a simple EF6 query

只愿长相守 提交于 2019-12-24 07:32:08
问题 I created a project that references a class library data layer project. The data layer is generated in Visual Studio using Code First from database : Add New Item => ADO.NET Entity Data Model => Code First from database I have selected all tables from a huge database (~1000 tables) and at the moment when I try to get something from any of the tables, it just hangs and eventually throws System.StackOverflowException . The query looks like that: using (var context = new MyDbModel()) { var test

nPLS-00306: wrong number or types of arguments in call

十年热恋 提交于 2019-12-24 06:46:02
问题 Excuse me if question is being repeated. I have two projects in my solution, a console application and a MVC4 website. I'm using Oracle managed drviers for accessing oracle database 11g. I'm trying to retrieve data from following stored procedure: create or replace procedure "GETEMPIDS" ( p_cursor OUT SYS_REFCURSOR ) is begin OPEN p_cursor FOR select * from EMP; end;​ After making entities and other stuff in my console application, I get data by doing: public List<GETEMPIDS_Result>

Build string method using complex type Entity Framework ASP.NET C#

≡放荡痞女 提交于 2019-12-24 06:33:59
问题 I had to use Entity Framework to equip an advanced search to my website application. The model is generated from the database and has own entities but has some complex stored procedure that returning mixed columns. To clarify, I have a customer entity with own columns but I want to use complex customer_Fetch_List_Result that is imported from the database to implement my advanced search. using (DbModel db = new DbModel()) { var query = db.customer_Fetch_List(ViewState["Gym"].ToString(), 0)

implement both EntityFramework 6 and EntityFramework Core side-by-side in a n-tier solution

寵の児 提交于 2019-12-24 06:08:05
问题 Here is an excerpt from Getting Started with ASP.NET Core and Entity Framework 6: "The recommended way to use Entity Framework 6 in an ASP.NET Core 1.0 application is to put the EF6 context and model classes in a class library project (.csproj project file) that targets the full framework. Add a reference to the class library from the ASP.NET Core project. " My Goal: is to implement both EntityFramework 6 and EntityFramework Core side-by-side in a n-tier solution. Solution: ASP.NET Core Web

implement both EntityFramework 6 and EntityFramework Core side-by-side in a n-tier solution

☆樱花仙子☆ 提交于 2019-12-24 06:07:28
问题 Here is an excerpt from Getting Started with ASP.NET Core and Entity Framework 6: "The recommended way to use Entity Framework 6 in an ASP.NET Core 1.0 application is to put the EF6 context and model classes in a class library project (.csproj project file) that targets the full framework. Add a reference to the class library from the ASP.NET Core project. " My Goal: is to implement both EntityFramework 6 and EntityFramework Core side-by-side in a n-tier solution. Solution: ASP.NET Core Web