entity-framework-6

How do I go about unit testing with Entity Framework and Moq?

你离开我真会死。 提交于 2019-12-03 08:19:58
I'm new to Moq, and wanting to use it like a backing store for data - but without touching the live database. My setup is as follows: A UnitOfWork contains all repositories, and is used for data access throughout the application. A Repository represents a direct hook into a DbSet, provided by a DbContext. A DbContext contains all DbSets. Here is my test so far: // ARRANGE var user = new User() { FirstName = "Some", LastName = "Guy", EmailAddress = "some.guy@mockymoqmoq.com", }; var mockSet = new MockDbSet<User>(); var mockContext = new Mock<WebAPIDbContext>(); mockContext.Setup(c => c.Set<User

Unable to determine the provider name for provider factory of type “System.Data.Sqlite.SqliteFactory”

你离开我真会死。 提交于 2019-12-03 07:50:13
问题 I want to use sqlite entity framework in my web api project, but it always can't work well, here is my development enviroment. 1.Visual studio 2013, .net framework 4.5 sqlite package version is 1.0.97, I installed below packages system.data.sqlite, system.data.sqlite.ef6, system.data.sqlite.linq EntityFramework is 6.1.3 Here is exception that I got Unable to determine the provider name for provider factory of type 'System.Data.SQLite.SQLiteFactory'. Make sure that the ADO.NET provider is

ASP.NET MVC5 - Keeping Users in Oracle Database

让人想犯罪 __ 提交于 2019-12-03 07:40:09
问题 Once creating a ASP.NET MVC5 project (with target framework is .NET 4.5.1 and the authentication type is Individual User Account ), so what is the most elegant way to configure the project so that it keeps the user, claims, roles etc. in an Oracle 12c database? I mean, how can I keep the authorization/authentication data in Oracle without deforming the automatically-generated MVC5 project structure. I guess changing the <defaultConnection> tag is not enough and there should be another Oracle

Entity Framework does not generates ObservableCollection

走远了吗. 提交于 2019-12-03 07:11:20
Im using EF6 in my dataentry program. EF does not generates ObservableCollection but HashSet and ICollection instead , so i have to change it manually. Unfortunately every time i Update Model from Database , every Many-Many relation goes back to ICollection ... Replace ICollection and HashSet with ObservableCollection in your .tt file. Then search for the method public string UsingDirectives . In this method there should be a line includeCollections ? (Environment.NewLine + "using System.Collections.Generic;") : "", . Replace only Generic with ObjectModel . This will include the correct

EF6 (code first), MVC, Unity, and a service layer without a repository

╄→尐↘猪︶ㄣ 提交于 2019-12-03 06:50:57
My application is using SQL Server 2012, EF6, MVC and Web API. It's also using a repository and assorted files such as: DatabaseFactory.cs Disposable.cs IDatabaseFactory.cs IRepository.cs IUnitOfWork.cs RepositoryBase.cs UnitOfWork.cs We already use a service layer between our controllers and the repository for some complicated business logic. We have no plans EVER to change to a different database and it has been pointed out to me that the recent thinking is that EF6 is a repository so why build another repository on top of it and why have all of the files I have above . I am starting to

WEB API JSON Serializing Circular References

 ̄綄美尐妖づ 提交于 2019-12-03 05:49:19
I'm trying to access the property fields (JSON) from the child entity that is received from Web API. By looking at the browser console, however, it is showing a reference instead of the fields. How do I get access to these fields? ANGULAR JS VIEW <table infinite-scroll='tF.loadMore()' infinite-scroll-disabled='tF.isBusy' infinite-scroll-distance='3' class="responsive"> <thead> <tr> <th>FIELD 1</th> <th>FIELD 2</th> <th>FIELD 3</th> <th>FIELD 4</th> <th>FIELD 5</th> </tr> </thead> <tbody> <tr ng-repeat="item in tF.items | filter:searchFilter"> <td>{{item.CompanyDomainModel.CompanyName}}</td>

Entity Framework edmx click on diagram very slow

…衆ロ難τιáo~ 提交于 2019-12-03 05:46:21
问题 Background first: I have a database-first EF6 model in Visual Studio 2015 (latest nuget 6.1.3 pointing to a local SQL Server 2014 SP1 Express database) on a Windows 10 Pro laptop. After I upgraded from Windows 8.1 and Visual Studio 2013. I also upgraded the model from EF5 about 6 months ago as well, but I don't think this is relevant, as I've also tried rebuilding from scratch. The model: set of about 100 tables, 50 views and 250 associations. The problem is every time I want to make changes

Visual Studio 2015 RC Entity Framework 6.1.3 Migrations Error

ⅰ亾dé卋堺 提交于 2019-12-03 05:38:45
The pasted below error only occurs when the solution has more than one project that references the EntityFramework. When run the "Enable-Migrations" or "Add-Migration", I received the following error: New-Object : The value supplied is not valid, or the property is read-only. Change the value, and then try again. At D:\Projetos\Monitoramento\packages\EntityFramework.6.1.3\tools\EntityFramework.psm1:757 char:13 + $info = New-Object System.AppDomainSetup -Property @{ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidData: (:) [New-Object], Exception + FullyQualifiedErrorId

Code-first: Mapping entities to existing database tables

元气小坏坏 提交于 2019-12-03 05:25:07
I am using Entity Framework 6 code-first with an existing database, but having problems mapping my entities to the database tables. Normally, I would use database-first approach and have my entity and context code generated, but using the designer has become a huge pain. I have set Database.SetInitializer(null) as I do not want EF to change my schema. Database schema: Code-first: public class Project { public int ProjectId { get; set; } public string Name { get; set; } public string Description { get; set; } } public class ReleaseControlContext : DbContext { public ReleaseControlContext() :

Support for Table Valued Functions in EF6 Code First?

谁说我不能喝 提交于 2019-12-03 05:17:41
Is it possible to call a TVF in EF6 Code First? I started a new project using EF6 Database first and EF was able to import a TVF into the model and call it just fine. But updating the model became very time consuming and problematic with the large read-only db with no RI that I'm stuck dealing with. So I tried to convert to EF6 code first using the Power Tools Reverse Engineering tool to generate a context and model classes. Unfortunately the Reverse Engineering tool didn't import the TVFs. Next I tried to copy the DBFunctions from my old Database First DbContext to the new Code First