ef

Is It Possible To Setup An Interface Library For A DAL Using Entity Framework?

匿名 (未验证) 提交于 2019-12-03 10:24:21
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I have a model library (namespace Test.App.Model.EF ) with the Entity Framework implementation in it. This has all of the entities provided in the EF designer for me which I want to use. Within this Model.EF implementation, I have several repository classes. I want to create interfaces for these classes and place them in a seperate interface library ( Test.App.Model.Interface ). So I do so, obviously the implementation library needs a reference the interfaces. BUT, I notice that the interfaces need to know about the objects in the

EF Migrations error: could not load type 'System.Data.Entity.Infrastructure.DbContextInfo'

匿名 (未验证) 提交于 2019-12-03 08:56:10
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am using ContosoUniversity example. I have just used Nuget to download and install code first migrations pakage. Whe I excecute update-database command it throws an error . Is there anything to do more than installing nuget package? Update-Database : Could not load type 'System.Data.Entity.Infrastructure.DbContextInfo' from assembly 'EntityFramework, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. At line:1 char:16 + update-database <<<< + CategoryInfo : NotSpecified: (:) [Update-Database], TypeLoadException +

Once again LINQ to SQL or Entity Framework for new MVC 3 project

匿名 (未验证) 提交于 2019-12-03 08:54:24
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: first of all, my background is: pretty large database (~100 tables with ~10-20 columns each) on MS SQL Server and it's always gonna be SQL Server and database first. i have some experience in WebForms and LINQ to SQL, but i'm sick of constructing forms for editing all that mentioned tables, so mvc 3 razor with it's Scaffolding just hypnotized me, and i'm dreaming of it generates all that forms for me but it comes out (or, maybe, i don't get something), that scaffolding works only for EF DbContext. for L2S it says 'unsupported

EF CF: many-to-many relation with additional info

匿名 (未验证) 提交于 2019-12-03 08:54:24
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: We have legacy database and we map the new objects and props to the old tables and columns. So far so good. We have many-to-many relation which was mapped successfully. The intermediate table contains additional data. When we try to map the intermediate table to an object we get exception that the mapping is already defined. If we remove mapping from any side of the relation we get error that table is missing (ofc, we expect just that). I can do that easily with NHibernate and I am starting to think that EF is missing really really many

EF. How to union tables, sort rows, and get top entities?

匿名 (未验证) 提交于 2019-12-03 08:54:24
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I want to union records from 2 tables, sort them, and read TOP rows from result set. T1 -------- Id, Timestamp, Text1 T2 -------- Id, Timestamp, Text2 With SQL it can be done this way: SELECT TOP 10 * FROM ( SELECT [Timestamp], [Text1] FROM T1 UNION SELECT [Timestamp], [Text2] FROM T2 ) as x ORDER BY [Timestamp] Q: How can I do that task using EF linq? 回答1: You need an anonymous type with the same property names and types before you can do an Union operation: var t1List = from a in allT1 select new { TimeStamp = a.TimeStamp, Text = a.Text1 }

Table not mapped to Entity Framework Data Model

匿名 (未验证) 提交于 2019-12-03 08:51:18
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Hi I'm back with another question,I have started using EF and I'm having problem with it. OverView: I made an EF model ,and found out that one table (named UserRoles) didn't showed up in the EF Model Diagram ,I tried to add it through "Update data model" ,but wizard didn't showed me that table to add (as if it was already added) ,I also tried to refresh model through "Update data model" wizard it was not helpful. Problem Explained: The original DB Diagram. Partial EF Model Diagram I tried to add it through "Update data model" I tried to

Replace first two whitespace occurrences with a comma using sed

匿名 (未验证) 提交于 2019-12-03 08:48:34
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a whitespace delimited file with a variable number of entries on each line. I want to replace the first two whitespaces with commas to create a comma delimited file with three columns. Here's my input: a b 1 2 3 3 2 1 c d 44 55 66 2355 line http://google.com 100 200 300 ef jh 77 88 99 z y 2 3 33 And here's my desired output: a,b,1 2 3 3 2 1 c,d,44 55 66 2355 line,http://google.com,100 200 300 ef,jh,77 88 99 z,y,2 3 33 I'm trying to use perl regular expressions in a sed command but I can't quite get it to work. First I try capturing a

EF not throwing DbUpdateConcurrencyException despite conflicting updates

匿名 (未验证) 提交于 2019-12-03 08:48:34
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am using EF 6.x (code-first) on a Web API server with web clients and I need to implement concurrency handling. The problem is that I cannot even get EF to generate an exception. Most examples that I have found seems to not be using "detached entities", where the DTO is sent to a web client where it is updated and then saved back to the server at a later time (which is my scenario). Let's say I have a Company record: public class Company { int CompanyId { get; set; } string CompanyName { get; set; } [Timestamp] public byte[] RowVersion {

Why EF generating a sub-query for a simle query?

匿名 (未验证) 提交于 2019-12-03 08:48:34
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: There is a simple Linq to EF: var query = from p in _db.Posts where p.BlogtId == blogId select p; It generates SQL in this form: SELECT `Extent1`.`PostId`, `Extent1`.`BlogId`, ... FROM `Posts` AS `Extent1` WHERE `Extent1`.`BlogId` = @p__linq__0 But when I add a order by to this query var query = from p in _db.Posts where p.BlogId == blogId orderby p.PublishDate select p; It generates this query SELECT `Project1`.`PostId`, `Project1`.`BlogId`, ... FROM (SELECT `Extent1`.`PostId`, `Extent1`.`BlogId`, ... FROM `Posts` AS `Extent1` WHERE

How to setup EF6 Migrations with ASP.NET Core

匿名 (未验证) 提交于 2019-12-03 08:35:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am trying to adopt Jimmy Bogard's ContosoUniversityCore project I would like to do code first migrations, but not sure how to properly set it up. I added Migrator.EF6.Tools to my project. When I run Enable-Migrations I get this error: Exception calling "SetData" with "2" argument(s): "Type 'Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.Automation.OAProject' in assembly 'Microsoft.VisualStudio.ProjectSystem.VS.Implementation, Version=14.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' is not marked as serializable."