entity-framework-6

Entity Framework Insert bug?

旧时模样 提交于 2019-12-14 04:07:21
问题 I used EF 6.2.0 DB first, SQL Server 2017 I created a table to test this create table Person ( ID int primary key, Name varchar(50) ) And I created a form to insert, this is button click event: private void btnSubmit_Click(object sender, RoutedEventArgs e) { Person p = new Person(); p.id =

Is there a simple way using data annotations or a custom type to use a value stored as a string in SQL as a DateTime in EF?

大憨熊 提交于 2019-12-14 03:26:17
问题 I have a database where all of the dates and times are stored as strings [yyyyMMdd] and [hhmmss] respectively. Is there a data annotation I can add in the POCO class so that it is recognised as the type that it should be? EG: [Column(TypeName="varchar(8)", Format="yyyyMMdd"] // Format does not

Entity Framework Lambda predicate stored in var with association

*爱你&永不变心* 提交于 2019-12-14 03:22:26
问题 I have a generic repository using EF6. The issue has to do with association properties requiring an "Include" even though it shouldn't. The following works: IQueryable<User> dbQuery = _db.Set<User>(); return dbQuery.Where(x => x.Child.Name == "Foo").ToList(); However, the following does not work:

Entity Framework The context cannot be used while the model is being created

淺唱寂寞╮ 提交于 2019-12-14 02:02:58
问题 My unit of work class is mentioned below and I am using Ninject and I have tried injecting IUnitOfWork per request per thread scope, transient etc. but I am still getting error which is: "Message":"An error has occurred.","ExceptionMessage":"The context cannot be used while the model is being

Error deploying to SQL Azure using EF 6 alpha3 Code First and Migrations creating __MigrationHistory table

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-14 01:32:11
问题 I'm using EF 6 alpha 3 code first. When I try to create the database on SQL Azure running the Update-Database command I get the following error: Tables without a clustered index are not supported in this version of SQL Server. Please create a clustered index and try again. I tracked down the

Asp.Net MVC and Strategy pattern

谁都会走 提交于 2019-12-13 22:04:19
问题 I have an MVC application that uses Entity Framework. I am using a repository, unit of work and unity as dependency injection. The problem I have is that I have different authentication types, and each type I want a different class, so I decided to use the Strategy pattern public interface

How to reflect the changing of my entities names to the navigation properties names

孤人 提交于 2019-12-13 21:24:53
问题 I have set of Entities generated according to DB First work flow in EntityFramework. The Entities have in proper names so i decide to change them but when i change the Entity name, the navigation property keeps the pluralization and the singularization of the old name like the following : Two