entity-framework-5

Entity Framework code first seems confused on my dbo table names after I tweaked the migration file

醉酒当歌 提交于 2019-12-11 12:56:47
问题 I've just begun using Entity Framework 5 (Code First Migrations). I think my issue may just be a given to someone that's worked with this a bit longer than I have (this is our first project giving it a go). I have 3 tables involved. One is a cross reference table. The gist of the classes is as follows: public class Person { //person properties public virtual List<Roles> Roles {get;set;} } public class Role { //Role properties public virtual List<Person> Persons {get;set;} } Adding a migration

C# LINQ Dynamic Select with all type of data

孤者浪人 提交于 2019-12-11 12:09:16
问题 I am implementing search by using dynamic LINQ, where the query gets column name and search value in runtime. In this way, I need to parse the data according to the column type- if (isNumeric) { int x = Int32.Parse(txtHistorySearch.Text); truncatedData = ((IQueryable<object>)rawData).Where(columnName + "=@0", x).ToList(); } else if (DateTime.TryParse(txtHistorySearch.Text, out temp)) { var parsedDt = DateTime.Parse(txtHistorySearch.Text); var nextDay = parsedDt.AddDays(1); truncatedData = (

Failed to encrypt destination web.config when using MS build plugin in Jenkins

给你一囗甜甜゛ 提交于 2019-12-11 12:06:34
问题 I am trying to setup Jenkins to build and deploy my ASP.net MVC project. My Command Line Arguments are /p:Configuration=Staging /p:DeployOnBuild=true /p:PublishProfile=Staging /p:ExcludeApp_Data=False /p:AllowUntrustedCertificate=True /p:LastUsedPlatform="Any CPU" /p:MSDeployPublishMethod=WMSVC /p:DeployIisAppPath=User Information Portal; /p:MsDeployServiceUrl=x.x.x.x /p:MSDeployEnableWebConfigEncryptRule=False /p:username=x /p:password=xx When Jenkins runs the project it always fails with an

EF generating “Specified method is not supported” error in SqlQuery

家住魔仙堡 提交于 2019-12-11 11:03:33
问题 I am currently using Entity Framework 5 I've tried to code the following: var result = context.Database.SqlQuery<Entity>("SELECT * FROM ref.Entity"); But I get the following error: Specified method is not supported. Can anyone show me a resolution to this issue? stack trace "at EFProviderWrapperToolkit.DbConnectionWrapper.CreateDbCommand()\r\n at System.Data.Common.DbConnection.CreateCommand()\r\n at System.Data.Objects.ObjectContext.CreateStoreCommand(String commandText, Object[] parameters)

foreach loop through different models in the view model to display links

删除回忆录丶 提交于 2019-12-11 10:10:35
问题 I have two tables called objects and apartments, which are "connected" with foreign keys called apartmentID and ObjectID . My controller and model are pretty simple: Model: using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace Projekt.Models { public class WrapperModel { public IEnumerable<Projekt.Models.objects> Objects { get; set; } public IEnumerable<Projekt.Models.apartments> Apartments { get; set; } } } And my controller is: using System; using

InvalidCastException when using Entity Framework

我怕爱的太早我们不能终老 提交于 2019-12-11 10:03:45
问题 I am trying to save a List of Users in a Conversation class but I am getting an InvalidCastException when performing a POST. This is my User class: public class User { [Key] [DataMember] public String Email { get; set; } [DataMember] public String Password { get; set; } [DataMember] public Boolean Admin { get; set; } public User(String email, String password, Boolean admin) { Email = email; Password = password; Admin = admin; } } And this is my Conversation class: [DataContract] public class

Entity Framework (.NET) Round-Trip Modelling with Model First?

时光总嘲笑我的痴心妄想 提交于 2019-12-11 09:53:08
问题 I am currently working on a project where I want to use the Entity Framework for the first time. I read much information in the books of Lerman/Miller, in MSDN, the ADO.NET blog and here on stackoverflow about the most recent developments regarding the DbContext API and the Code First Migrations capabilities available since EF 4.3. Since especially the latter are really great, I wondered whether in the meantime it is possible to do the same working "Model First" centered? Is it possible to do

Custom Entity Framework many-to-many navigation property

两盒软妹~` 提交于 2019-12-11 09:51:08
问题 I have a many-to-many mapping/pivot table I had to expose as an Entity in order to model a relationship similar to the following (as per this question Model Entity Framework many-many plus shared relation): Now, I would like to emulate the EF collection Enumerate/Add/Remove functionality that is present on the navigation property of a 'stock' Entity Framework many-to-many relationship. How would I do that? I'm hoping for something that I can still query without blowing my data performance.

Set the binding of a dropdown in knockout to an object

狂风中的少年 提交于 2019-12-11 09:33:14
问题 I am trying to trying to set a the binding a drop down list (kendo drop down) uses to a full object. I am using Knockout-Kendo to accomplish the binding but I don't think the kendo stuff or knockout-kendo stuff is a factor in my problem. For example I have the following object var model = { "Client": null, "Clients": [ { "CompanyAccount": { "RelationshipManager": {}, "CompanyAccountId": 1, "Name": "My Company Name", "PhoneNumber": "(555) 555-5555", "Address": { "State": { "StateId": 6, "Name"

Model Entity Framework many-many plus shared relation

末鹿安然 提交于 2019-12-11 09:27:30
问题 In Entity Framework (model-first), I'm implementing a many-many (e.g. Composition-Anthology) relationship, with an additional relation (Composer) that must match within related sets. How can I correctly create this model in EF? I currently have two bad ideas: Bad Idea #1 By making the primary keys on Composition and Anthology composites, containing both ComposerId and the local Identity, EF constrains this correctly. However this causes immediate problems: All tables related to Composition