entity-framework

c# System.Data.SqlClient.SqlException: Snix_Connect in macOS

我们两清 提交于 2021-02-08 08:18:33
问题 I am writing an asp.net 5 app with ef 7 to work with sql server. It's all okay when the app is running under windows. When I tried running it under macOS and when i need to interact with the database the following exception appeared: Unhandled Exception: System.Data.SqlClient.SqlException (0x80131904): Snix_Connect (provider: SNI_PN7, error: 25 - SNI_ERROR_25) Snix_Connect (provider: SNI_PN7, error: 25 - SNI_ERROR_25) ---> System.Net.Sockets.SocketException (0x80004005): The socket is not

c# System.Data.SqlClient.SqlException: Snix_Connect in macOS

∥☆過路亽.° 提交于 2021-02-08 08:18:12
问题 I am writing an asp.net 5 app with ef 7 to work with sql server. It's all okay when the app is running under windows. When I tried running it under macOS and when i need to interact with the database the following exception appeared: Unhandled Exception: System.Data.SqlClient.SqlException (0x80131904): Snix_Connect (provider: SNI_PN7, error: 25 - SNI_ERROR_25) Snix_Connect (provider: SNI_PN7, error: 25 - SNI_ERROR_25) ---> System.Net.Sockets.SocketException (0x80004005): The socket is not

How to build inverse relationship to Entity which has more than two relationship to it?

流过昼夜 提交于 2021-02-08 08:04:37
问题 I have an entities Group and Person with relationships: Group: Group.leader -> Person (To One) Group.looser -> Person (To One) Group.others ->> Person (To Many) In leader , looser and others set I could have different Person entities. Same Person could be leader in one group, looser in second and appears in others set in third group. in Person entity I have To-Many relationship groups which should connect Person: Person.groups ->> Group (should be enough but warnings) Because I can make only

How to build inverse relationship to Entity which has more than two relationship to it?

守給你的承諾、 提交于 2021-02-08 08:01:32
问题 I have an entities Group and Person with relationships: Group: Group.leader -> Person (To One) Group.looser -> Person (To One) Group.others ->> Person (To Many) In leader , looser and others set I could have different Person entities. Same Person could be leader in one group, looser in second and appears in others set in third group. in Person entity I have To-Many relationship groups which should connect Person: Person.groups ->> Group (should be enough but warnings) Because I can make only

Cast error with Entity Framework and Lists in C#

人走茶凉 提交于 2021-02-08 07:35:23
问题 I create a generic function to get a specific page for an EntityObject collection: public static IList<EntityObject> GetPageItemsOfCollection(IQueryable<EntityObject> collectionIQueryable, int startIndex, int pageSize) { if (collectionIQueryable == null) return null; return collectionIQueryable.Skip(startIndex).Take(pageSize).ToList(); } When I try to user this function like this: IQueryable<EntityObjectSubClass> entityObjectSubClassIQueryable = GetEntityObjectSubClassIQueryableBySomeFilter

Entity Framework Plus - FutureValue() in a foreach loop

怎甘沉沦 提交于 2021-02-08 07:33:27
问题 Recently I started using EF+ on our project with great success however sometimes I run into an issue that I have a set of entities for which I need to run a separate query. So if I have a set of 20 customers I need to run 20 queries separately. I wonder if there is way how to avoid this using EF+ FutureValue() somehow in a foreach loop. See this sample code: foreach (var customer in customers) { customer.SomeValue = ctx.SomeDatabaseTable.Where(myCondition).FutureValue(); // this would run 20

How to show a list of information on the fly in a razor component

和自甴很熟 提交于 2021-02-08 07:22:46
问题 I have a database and a lot of entries in a table. I want to show those entries on a webpage, using blazor. I have tried loading the entries using context.tableName.Load() and context.tableName.Local and iterating through the entries using @foreach(var entry in localList){ <p>@entry.Name</p> } That works fine.. but it first loads all the data from the database and when it finally has finished, it starts rendering the page/results. I want to show the results that have been loaded immediately,

Entity framework override save changes to soft delete entities

北城以北 提交于 2021-02-08 05:37:15
问题 I am trying to override Savechanges in My Database Context to mark my entites as SoftDeleted. I have an ISoftDeletable base which i override in my Entity classes public interface IsoftDeletable { public bool IsDeleted {get; set;} } And then in my Context public override int SaveChanges() { foreach (var entry in ChangeTracker.Entries() .Where(p => p.State == EntityState.Deleted)) SoftDelete(entry); return base.SaveChanges(); } private void SoftDelete(DbEntityEntry entry) { var entity = entry

ASP.NET MVC - Switching from SQL Server Express to Compact Edition - Connection Issue

China☆狼群 提交于 2021-02-08 05:24:14
问题 I have a ASP.NET MVC 4 project - CodeFirst with Entity Framework - that was connected to a SQL Server Express database generated by EF and it was working just fine. However, I am trying to deploy to AppHarbor and having some issues with the version of SQL running there connecting with my app. So, I noticed that they have an example project that is utilizing SQL Server Compact Edition 4. Here is the web.config file for that project: https://github.com/friism/CodeFirstMigrations/blob/master/Web

An item with the same key has already been added - Just in Release mode

南楼画角 提交于 2021-02-08 03:45:29
问题 Experts, I'm getting this System.ArgumentException ( An item with the same key has already been added ) at the very first use of an entity framework function at runtime. The strange thing: If I'm using debug mode, it works fine. After compiling the same code without any changes made in release mode , it crashes immediatly with exception mentioned at top of this post. Does anyone know more about such a strange behaviour? How can I fix it? I cannot roll out a debug version to my customer :(