entity-framework

EF models. Navigation properties can only participate in a single relationship

随声附和 提交于 2020-01-24 16:00:11
问题 I have my entities like this, they are closely linked. public class Game { public int Id { get; set; } public int FirstTeamId { get; set; } public Team FirstTeam { get; set; } public int SecondTeamId { get; set; } public Team SecondTeam { get; set; } public Stadium Stadium { get; set; } public DateTime Date { get; set; } public GameStatus Result { get; set; } public Game(DateTime date , GameStatus result ) { Date = date; Result = result; } } public class Player { public int Id { get; set; }

EF models. Navigation properties can only participate in a single relationship

放肆的年华 提交于 2020-01-24 16:00:06
问题 I have my entities like this, they are closely linked. public class Game { public int Id { get; set; } public int FirstTeamId { get; set; } public Team FirstTeam { get; set; } public int SecondTeamId { get; set; } public Team SecondTeam { get; set; } public Stadium Stadium { get; set; } public DateTime Date { get; set; } public GameStatus Result { get; set; } public Game(DateTime date , GameStatus result ) { Date = date; Result = result; } } public class Player { public int Id { get; set; }

Match 2 property of any object in local list using Linq

徘徊边缘 提交于 2020-01-24 15:09:33
问题 public class OrderItem { public int OrderID { get; set; } public int ProductionID { get; set; } } public class InventoryItem { public int InventoryItemID{ get; set; } public int OrderID { get; set; } public int ProductionID { get; set; } public bool Created { get; set; } public bool Deleted { get; set; } } Using these example objects, I have a local list of orderItems and want to query inventory items where OrderID and ProductionID matches on both properties any of my list of Order Items I

What would be the consequences if I disable the ProxyCreation globally in Entity Framework?

自闭症网瘾萝莉.ら 提交于 2020-01-24 14:14:25
问题 The Entity Framework uses proxy classes for some of its internal stuff, as seen in this question we have to disable it, because it cause issues with the serialization of the objects. My question is what will be the consequences if I disable the ProxyCreation globally in my project (to avoid serialization issues) ...??? 回答1: They are mainly around enabling lazy loading, but can provide some performance improvement for persisting changes, though honestly I'd say this is highly situational to

Setup one to many relation with fk having multiple rows

不羁的心 提交于 2020-01-24 13:55:52
问题 I have a problem with setting up a one-to-many relation with EF Core. I have two tables address and address_country . There are schemas: As you see, I want to store countries with different locales. So it has a composed key. address table has a foreign key to address_country . Unfortunately, I cannot setup ContextDb to achieve what I want. The list of countries is not filled in Address model. I have the following code in Context : public class Context : DbContext { protected override void

SET IDENTITY_INSERT [table] ON not working

拈花ヽ惹草 提交于 2020-01-24 12:36:12
问题 I want to insert some records where I specify the Id, for the purpose of migrating data where I would like to maintain the integrity of existing relationships. To do this I ran this command directly in SSMS on the table: SET IDENTITY_INSERT [CRMTItem] ON; Yet, when I insert an item from C# with Id of 1, the Id is still incrementing from around 850. I deleted the entities from EDMX and updated again from DB but with the same result. Here is my insert code, where as you can see I am ensuring

SET IDENTITY_INSERT [table] ON not working

两盒软妹~` 提交于 2020-01-24 12:35:17
问题 I want to insert some records where I specify the Id, for the purpose of migrating data where I would like to maintain the integrity of existing relationships. To do this I ran this command directly in SSMS on the table: SET IDENTITY_INSERT [CRMTItem] ON; Yet, when I insert an item from C# with Id of 1, the Id is still incrementing from around 850. I deleted the entities from EDMX and updated again from DB but with the same result. Here is my insert code, where as you can see I am ensuring

Is OData suitable for multi-tenant LOB application?

ぐ巨炮叔叔 提交于 2020-01-24 10:26:27
问题 I'm working on a cloud-based line of business application. Users can upload documents and other types of object to the application. Users upload quite a number of documents and together there are several million docs stored. I use SQL Server. Today I have a somewhat-restful-API which allow users to pass in a DocumentSearchQuery entity where they supply keyword together with request sort order and paging info. They get a DocumentSearchResult back which is essentially a sorted collection of

Foreign key with composite key in EF Core

巧了我就是萌 提交于 2020-01-24 10:17:30
问题 I have the following classes: public class ProductAttribute { public Guid ProductId { get; set; } public Guid AttributeId { get; set; } public List<ProductAttributeValue> Values { get; set; } public object[] GetKeys() { return new object[] {ProductId, AttributeId}; } } public class Product { public Guid Id { get; set; } public string Name { get; set; } } public class Attribute { public Guid Id { get; set; } public string Name { get; set; } } public class ProductAttributeValue { public Guid Id

Converting JSON object to Data.Entities.Models.MyModel

柔情痞子 提交于 2020-01-24 09:54:09
问题 So, I'm having an issue with serializing my JSON object to my Entity/Model object. I have the following code snippet: var serializedValue = JsonConvert.SerializeObject(newRows, new MyModelConverter()); var csvToSave = JsonConvert.DeserializeObject<MyModel>(serializedValue); Where newRows is a List<KeyValuePair<string,string>> Where Entity looks something like this: public class MyModel: Entity { public int Id { get; set; } //primary key public DateTime TouchTime { get; set; } public DateTime