entity-framework

ASP.NET Core DbContext injection

会有一股神秘感。 提交于 2020-06-25 09:02:28
问题 I have a ConfigurationDbContext that I am trying to use. It has multiple parameters, DbContextOptions and ConfigurationStoreOptions . How can I add this DbContext to my services in ASP.NET Core? I have attempted the following in my Startup.cs: ConfigureServices .... services.AddDbContext<ConfigurationDbContext>(BuildDbContext(connString)); .... private ConfigurationDbContext BuildDbContext(string connString) { var builder = new DbContextOptionsBuilder<ConfigurationDbContext>(); builder

What are the Navigation Properties in Entity Framework

半城伤御伤魂 提交于 2020-06-25 00:15:17
问题 I am new to Entity Framework. When the Visual Studio creates Model diagram we can see mainly two things in Entities.Propertie and Navigation Properties,So what are these Navigation Properties? How to use them? 回答1: Navigation properties represents related entites to the principal entity. Foreign Keys are usually represented by navigation properties. Ex : if you have two tables Invoice and invoice items and those tables have a relation 1-> many so you'll find a navigation property in invoice

What are the Navigation Properties in Entity Framework

喜欢而已 提交于 2020-06-25 00:13:51
问题 I am new to Entity Framework. When the Visual Studio creates Model diagram we can see mainly two things in Entities.Propertie and Navigation Properties,So what are these Navigation Properties? How to use them? 回答1: Navigation properties represents related entites to the principal entity. Foreign Keys are usually represented by navigation properties. Ex : if you have two tables Invoice and invoice items and those tables have a relation 1-> many so you'll find a navigation property in invoice

What are the Navigation Properties in Entity Framework

爷,独闯天下 提交于 2020-06-25 00:13:32
问题 I am new to Entity Framework. When the Visual Studio creates Model diagram we can see mainly two things in Entities.Propertie and Navigation Properties,So what are these Navigation Properties? How to use them? 回答1: Navigation properties represents related entites to the principal entity. Foreign Keys are usually represented by navigation properties. Ex : if you have two tables Invoice and invoice items and those tables have a relation 1-> many so you'll find a navigation property in invoice

Entity Framework Oracle Timestamp

纵饮孤独 提交于 2020-06-24 16:46:51
问题 We have T_SC_SERVICE table with a INSTANCE_ID column which is type Timestamp(6) in Oracle. I'm using .NET Framework 4.5, Entity Framework 6 and DB first approaches. I'm trying to Add and Select item from this table with using LINQ. Insert with LINQ as shown below: Service newItem = new Service() { InstanceId = DateTime.Now, }; this.ObjectSet.Add(newItem); this.SaveChanges(); That LINQ generates SQL as below. As you can see INSTANCE_ID parameter is send as a DateTime as expected. insert into

The data types nvarchar(max) encrypted with with (encryption_type = 'DETERMINISTIC' xxx) are incompatible in the equal to operator

夙愿已清 提交于 2020-06-23 14:07:36
问题 var countryCode = new SqlParameter("@countryCode", SqlDbType.VarBinary); var byteArray = Encoding.UTF8.GetBytes(dto.Country); countryCode.Value = byteArray; var country = new SqlParameter("@country", "country"); country.Value = "country"; var rawUsers = DbContext.Users.FromSqlRaw("Select u.* from AspNetUsers u join AspNetUserClaims uc on u.Id = uc.UserId where uc.ClaimType = @country and uc.ClaimValue = @countryCode", country, countryCode) .ToList(); ERROR: [17:16:22 ERR] Error:The data types

How do I solve SqlNullValueException?

你离开我真会死。 提交于 2020-06-23 07:29:16
问题 I'm trying to find an entity but I get a SqlNullValueException when entity framework is trying to get the value of a field that's Null. I checked in the database and all the not nullable fields are filled. The only fields that have a NULL value are the ones that are allowed to have it. In other answers I found that I should remove required attribute from the class properties or remove the IsRequired method from modelbuilder definition, however I autogenerated these and they never had a

ThenInclude not recognized in EF Core query

两盒软妹~` 提交于 2020-06-22 17:53:45
问题 My IQueryable looks like this: IQueryable<TEntity> query = context.Set<TEntity>(); query = query.Include("Car").ThenInclude("Model"); 'IQueryable' does not contain a definition for 'ThenInclude' and no extension method 'ThenInclude' accepting a first argument of type 'IQueryable' could be found (are you missing a using directive or an assembly reference?) I have all references needed: using Content.Data.Models; using Microsoft.EntityFrameworkCore; using System; using System.Collections

How to map exisiting sql server view with EF code first

点点圈 提交于 2020-06-22 10:36:30
问题 i am fairly new in EF and learning EF code first. i am looking for a knowledge to map exisiting sql server view with EF code first. i have map my view with POCO but getting the below error. when i try to fetch data from view then got the below error thrown Additional information: The model backing the 'TestDBContext' context has changed since the database was created. Consider using Code First Migrations to update the database my full code as follow public class TestDBContext : DbContext {

How to map exisiting sql server view with EF code first

。_饼干妹妹 提交于 2020-06-22 10:36:25
问题 i am fairly new in EF and learning EF code first. i am looking for a knowledge to map exisiting sql server view with EF code first. i have map my view with POCO but getting the below error. when i try to fetch data from view then got the below error thrown Additional information: The model backing the 'TestDBContext' context has changed since the database was created. Consider using Code First Migrations to update the database my full code as follow public class TestDBContext : DbContext {