entity-framework

EF - Require either of two fields?

旧巷老猫 提交于 2020-01-16 04:20:06
问题 Is there a way to do what this question is doing (Either Or Required Validation) but instead of applying it on the entire class, I only want to apply the validation on two specific fields within the class. For example public class FooModel { [Required] public string Name { get; set; } [Required] public decimal Cost { get; set; } public int Bar1 { get; set; } public float Bar2 { get; set; } } I only want to constrain Bar1 and Bar2 to be an either/or requirement. They cannot both be null. Is

Warning ASP.NET runtime error: Could not load file or assembly 'EntityFramework, Version=6.0.0.0

回眸只為那壹抹淺笑 提交于 2020-01-16 02:55:28
问题 I'm developing using ASP.NET in Microsoft Visual Studio Express 2012 for Web. Everything works great but suddenly when changing some code in one of my controllers Visual Studio crashed and now I got this weird runtime error: Warning 1 \Views_Create.cshtml: ASP.NET runtime error: Could not load file or assembly 'EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E

Custom Convention for table with Prefix Entity Framework

眉间皱痕 提交于 2020-01-16 02:08:08
问题 All my POCO classes have two letter prefix LK_. Entity framework conventions for primary & foreign keys would not work. Considering I have ~200 classes to decorate with Key or ForeignKey attribute its a cumbersome process & does not sound like a smart way of doing it. Could you please suggest custom convention? public class LK_Employee { public Guid EmployeeID {get; set;} public string Name {get; set;} } public class LK_Company { public Guid CompanyID {get; set;} public string Name {get; set;

Having troubles loading related entities (Eager Load) with ObjectContext.CreateQuery (Entity Framework and Repositories)

ⅰ亾dé卋堺 提交于 2020-01-16 02:06:27
问题 Here's a bunch of things I tried... hopefully you can extrapolate from it what I'm trying to do and what I'm doing wrong. Okay so I'm having problems with loading related entities when using this DoQuery: public ObjectQuery<E> DoQuery(ISpecification<E> where) { return (ObjectQuery<E>)_ctx.CreateQuery<E>("[" + typeof(E).Name + "]").Where(where.EvalPredicate); } If I just use this, I end up getting an object back that contains all proper parameters except the ones that are related entities...

Using expression trees to create a custom order by in linq to entities

让人想犯罪 __ 提交于 2020-01-16 01:53:13
问题 I have a table that's mapped, but after compile additional columns can be added or removed from the table. I'm trying to come up with a linq query that will take those new columns into account. In this scenario, I want to order by one of those dynamic columns. This is what I have so far. var queryableData = dc.wf_task_ext_attributes.AsQueryable(); ParameterExpression pe = Expression.Parameter(typeof(DateTime), "ExtValue105"); // The next line is where it fails MethodCallExpression

Using TryUpdateModel to save an object on Edit Post with FormCollection

不羁岁月 提交于 2020-01-16 01:33:08
问题 I'm not sure I understand the best way of doing this. If I have a model with a large number of fields, then do I have to explicitelly list every one of them in a whitelist under TryUpdateModel, or can I just pass the ForCollection. The following code doesn't save my edits, is my only alternative to list all my fields one by one? public ActionResult Edit(int id, FormCollection form) { var jobToUpdate = db.Jobs .Include(x => x.JobNotes) .Where(x => x.JobID == id) .SingleOrDefault(); if

Entity Framework 6 + Code First + Oracle 11g

▼魔方 西西 提交于 2020-01-16 00:49:12
问题 Is there any way to create 100% the Oracle11g database using EF Code First? And how to trace the Oracle query in SaveChanges? 回答1: You can use third party to have a code first solution with oracle and ef 6 one of this providers is DevArt you can read more about the support here Ef6 in devart And about the log you can enable log in ef6 as is explained here http://msdn.microsoft.com/pt-br/data/dn469464 回答2: Try oracle odac 12c release 3, but only support EF6 code first. 回答3: I know its 2015 and

How to implement a one-to-many relationship with an “Is Current” requirement

北战南征 提交于 2020-01-15 15:31:14
问题 Designing a database, there's a relationship between two tables, Job and Document . One Job can have multiple Documents , but one (and only one) of these Documents needs to be flagged as IsCurrent . This is not always the most recent Document associated with that Job . Structurally, I can see two ways of doing this. The first is to add a DocumentId column to Job , and a JobId column to Document . This will work, but creates a circular reference: when imported into Entity Framework you end up

MVC Getting Error - CREATE DATABASE permission denied

纵饮孤独 提交于 2020-01-15 12:47:29
问题 I am using MVC first time, and I got this error when running the application. Here are my steps. Create a new MVC empty Project Install Entity framework 5.0.0 ( PM> Install-Package EntityFramework -Version 5.0.0 ) Add two classes in Model- MovieReview.cs and MovieReviewContext.cs . MovieReview Class is this And MovieReviewContext Class is this In Controllers folder I add a new Controller, named HomeController. Here is it . Then I run it on Google Chrome or on IE. And I got the error I

Is there any standard approach for defining projects in an ASP.NET MVC solution? [closed]

丶灬走出姿态 提交于 2020-01-15 12:32:27
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 6 years ago . How should I logically define an ASP.NET MVC solution? Into how many projects must I divide my solution? Is there a standard approach