entity-framework

what is difference between inverse property and foreign key in entity framework?

烂漫一生 提交于 2020-02-26 07:13:33
问题 I knew that Inverse Property is used when you have multiple relationships between classes. but I am confused between inverse property and foreign key property since both of them are used for defining relationships. public class PrivilegeToDbOperationTypeMap : BaseEntity { [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity), Column(Order = 0)] public int PrivilegeToDbOperationTypeMapId { get; set; } [ForeignKey("privilegeLookup"), Column(Order = 1)] [Index("IX_PrivilegeLookupId

what is difference between inverse property and foreign key in entity framework?

我与影子孤独终老i 提交于 2020-02-26 07:12:24
问题 I knew that Inverse Property is used when you have multiple relationships between classes. but I am confused between inverse property and foreign key property since both of them are used for defining relationships. public class PrivilegeToDbOperationTypeMap : BaseEntity { [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity), Column(Order = 0)] public int PrivilegeToDbOperationTypeMapId { get; set; } [ForeignKey("privilegeLookup"), Column(Order = 1)] [Index("IX_PrivilegeLookupId

Add-Migration while using database in separate Docker container throws an error

情到浓时终转凉″ 提交于 2020-02-25 06:30:08
问题 I've created dockerized ASP.net Core app with auto-generated identity setup (so I've already had by default entity framework configuration). I've created SQL Server as separate container, here is my docker-compose.yml : version: '3.4' services: blazorapp1: image: blazorapp1 build: context: . dockerfile: Dockerfile depends_on: - db db: image: "mcr.microsoft.com/mssql/server" environment: SA_PASSWORD: "[SOMEPASSWORD]" ACCEPT_EULA: "Y" I've tested database configuration: as Visual Studio

When executing the command “Scaffold-DbContext” I get the error “ScriptHalted”

◇◆丶佛笑我妖孽 提交于 2020-02-25 05:42:27
问题 I am trying to compute the entity framework tutorial" Creating a Model for an Existing Database in Entity Framework Core // entityframeworktutorial.net"- When I enter the command: PM> Scaffold-DbContext" Server =. \ SQLEXPRESS1; Database = SCHOOLDB.MDF; Trusted_Connection = True; " Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models I get the error: ScriptHalted Database Picture Used by: - Visual Studio - 2019. Community - 16.3.6; - Console application. Core 3.0; - Microsoft

How to make Exists with Dynamic Linq

﹥>﹥吖頭↗ 提交于 2020-02-25 03:18:27
问题 How to do I make exists with dynamic LINQ? I'm trying to create an SQL clause with dynamic LINQ. I researched a lot of and not found an satisfactory answer. I try convert the SQL query as follows: SQL select * from Documento where exists( select 1 from Titulo where Documento.codDocumento = Titulo.codDocumento and Documento.codEmpresa = Titulo.codEmpresaDocumento and Titulo.codFluxoConta = 'SomeValue' and Titulo.codEmpresaFluxoConta = 'StringNumerical') In common LINQ I did as follows: var

Dynamic Select EntityFramework and System.Linq.Dynamic

牧云@^-^@ 提交于 2020-02-24 17:58:51
问题 Im using the DynamicQueryable.Select() // dynamic select library The only docu I have found so far is System.Linq.Dynamic docu I have this query with anonymous return type which works. var result = Context.Set<TPocoText>().Where((Expression<Func<TPocoText, bool>>) whereLambda) .OrderByDescending(t => t.RowVersion).Skip(skip).Take(take) .Select("new (m1,m2,Nav1) "); and this works like select(t=> new {t.m1,t.m2,t.Nav1}) as expected my Question How can it do the equivalent of select(t=> new {t

Invalid SQL Server Connection String on Linux Entity Framework Core

ぃ、小莉子 提交于 2020-02-24 14:08:37
问题 I'm using Linux more specifically Xubuntu. I have installed SQL Server Express on my machine. I'm currently in the making of a web app and my connection does not seem working or I don't understand everything quite right? The output I get is : A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections.

List returned by Entity Framework is null [duplicate]

蓝咒 提交于 2020-02-24 10:20:51
问题 This question already has an answer here : EF Core returns null relations until direct access (1 answer) Closed 18 days ago . I have these two classes, Field and Field2 with a one-to-many relationship. When I am trying to get Field , the list returns with records with the id and the name, which is correct. But trying to read the Field2 from Field is always empty. What can be the cause? I have tried everything. I can see the FK in the database etc. public class Field : IEntityBase { public int

List returned by Entity Framework is null [duplicate]

試著忘記壹切 提交于 2020-02-24 10:15:15
问题 This question already has an answer here : EF Core returns null relations until direct access (1 answer) Closed 18 days ago . I have these two classes, Field and Field2 with a one-to-many relationship. When I am trying to get Field , the list returns with records with the id and the name, which is correct. But trying to read the Field2 from Field is always empty. What can be the cause? I have tried everything. I can see the FK in the database etc. public class Field : IEntityBase { public int

EF4 two models one database, possible?

社会主义新天地 提交于 2020-02-24 04:13:10
问题 I have been searching for this answer and can't seem to find anything, but with EF4 I want to create a base model and put in our 'foundation' and any new project we create if we need to add custom tables to that sites db is it possible to add a model with just those specific tables and link it to the model in our 'foundation' I can't seem to find a good resource on something like this and this seems to be like it would be a normal thing to have a reusable base model and a separate one for any