ef

Using a EF Repository with custom connection objects?

匿名 (未验证) 提交于 2019-12-03 07:36:14
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am stuck in EF 6 and the documentation is sparse - not getting that solved for a day now. I try to use Code First on a database repository we have. Due to complex initialization I must use my own factory method to initialize the context subclass and I must put my own sql connection in, or make my own factory. THe following class initialization: we have: public class Repository : DbContext { static string _connectionString; static Repository() { Database.SetInitializer<Repository>(null); var type = typeof(System.Data.Entity.SqlServer

How to upgrade from Entity Framework 4.3 to EF 5

匿名 (未验证) 提交于 2019-12-03 02:49:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Currently we are working on the EF 4.3 . We would like to upgrade it to EF5. I have google the upgrade process steps, but I did not get any result. Please help me..! Thanks.. :) 回答1: Here are two links for you of content I've created on EF4.3 to EF5: article: Moving Existing Projects to EF 5 http://msdn.microsoft.com/en-us/magazine/jj618295.aspx video: Entity Framework 5 Enums and Moving Solution from EF 4.3 http://thedatafarm.com/blog/data-access/video-entity-framework-5-enums-and-moving-solution-from-ef-4-3/ hth julie 文章来源: How to upgrade

“There was an error running the selected code generator” in VS 2013 scaffolding

匿名 (未验证) 提交于 2019-12-03 02:44:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm creating a new view off of a model. The error message I am getting is Error There was an error running the selected code generator: 'Access to the path 'C:\Users\XXXXXXX\AppData\Local\Temp\SOMEGUID\EntityFramework.dll' is denied'. I am running VS 2013 as administrator. I looked at Is MvcScaffolding compatible with VS 2013 RC by command line? but this didn't seem to resolve the issue. VS2013 C#5 MVC5 Brand new project started in VS 2013. 回答1: VS2013 Error: There was an error running the selected code generator: ' A configuration for type

Json.Net adding $id to EF objects despite setting PreserveReferencesHandling to “None”

匿名 (未验证) 提交于 2019-12-03 02:38:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I've already looked at how to remove $id during JSON serialization but the answers given do not seem to be working for me and I hope someone can figure out what I am doing wrong. Here is my code: return JsonConvert . SerializeObject ( target , new JsonSerializerSettings { NullValueHandling = NullValueHandling . Include , PreserveReferencesHandling = PreserveReferencesHandling . None , ContractResolver = new CustomContractResolver (), Converters = CustomConverters }); The output from this is still coming out with $id's, BUT, only on

The mapping of CLR type to EDM type is ambiguous with EF 6 &amp; 5?

匿名 (未验证) 提交于 2019-12-03 02:29:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Please any one can help me to fix this error? Schema specified is not valid. Errors: The mapping of CLR type to EDM type is ambiguous because multiple CLR types match the EDM type 'City_DAL'. Previously found CLR type 'CeossDAL.City_DAL', newly found CLR type 'CeossBLL.City_DAL'. The main problem that I have DAL and this contains the EF and BLL and this contains the same classes of the DAL but differ in the namespace and this is what cause the problem I can't know how to get rid of these problem, can you please help me? Also I will be

EF Core (1.0.0) Migrations On Azure App Services

匿名 (未验证) 提交于 2019-12-03 02:20:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: We have a web app (Net Core 1.0.0-preview2-003121) deployed to an Azure App Service and we're struggling to deploy the migrations. In RC1/2 it was possible to do the migrations with an ef.cmd file that seemed to be automagically there, namely we could use this file to run dnx ef database update but this is gone. dotnet ef is not installed in the Azure App Service itself, so this is not an option. Any ideas that don't involve running the migrations from code/deploying them from visual studio? We're trying to build a continuous deployment

使用EF批量新增数据十分缓慢

笑着哭i 提交于 2019-12-03 02:19:59
使用EF来批量新增数据,发现效率非常的差,几千条数据时甚至需要几分钟来执行,迫于无奈使用sql来执行了。 今天偶然看到一篇关于EF的文章,才发觉原来是自己对EF不够了解的原因。 一般新增时我们是将所有的记录都添加到了同一个上下文中了,EF会对我们新增的这些记录进行追踪,随着我们增加的记录越来越多,EF追踪的对象图自然就越来越大了,然后对我们来说效率就会飞速下降。 解决办法 1是可以关闭自动调用context.Configuration.AutoDetectChangesEnabled=false 2是使用多个上下文进行批量新增 附上原文链接: https://www.cnblogs.com/CreateMyself/p/8989983.html 来源: https://www.cnblogs.com/Cyril-hcj/p/11771121.html

How can I resolve this error: Loading the include file &#039;EF.Utility.CS.ttinclude&#039; returned a null or empty string

匿名 (未验证) 提交于 2019-12-03 02:16:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: How can I resolve these errors: Loading the include file 'EF.Utility.CS.ttinclude' returned a null or empty string. Value does not fall within the expected range. Tools Used: VS 2012, Entity Framework 5.0.0, T4MVCExtensions 3.5.0, .NET Framework 4.5 I've been using EF and T4 templates in a project within a large MVC solution without incident. Now, when I right-click on the edmx diagram, EF responds with the message: Value does not fall within the expected range. When I compile the EF project it responds with these messages: Loading the

EF Data Context - Async/Await &amp; Multithreading

匿名 (未验证) 提交于 2019-12-03 02:12:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I frequently use async/await to ensure ASP.NET MVC Web API threads are not blocked by longer-running I/O and network operations, specifically database calls. The System.Data.Entity namespace provides a variety of helper extensions here, such as FirstOrDefaultAsync , ContainsAsync , CountAsync and so forth. However, since data contexts are not thread safe, this means that the following code is problematic: var dbContext = new DbContext (); var something = await dbContext . someEntities . FirstOrDefaultAsync ( e => e . Id == 1 ); var

Can I store enums as strings in EF 5?

匿名 (未验证) 提交于 2019-12-03 01:49:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: We have been using EF CF for a while in our solution. Big fans! Up to this point, we've been using a hack to support enums (creating an extra field on the model; ignore the enum durring mapping; and map the extra field to the column in the db that we would have used). Traditionally we have been storing our enums as strings(varchars) in the DB (makes it nice and readable). Now with enum support in EF 5 (Beta 2) it looks like it only supports mapping enums to int columns in the DB....Can we get EF 5 to store our enums as their string