entity-framework

Customize materialization process in an entity framework provider

我的梦境 提交于 2020-01-15 12:29:07
问题 I have a problem with booleans returned by an entity framework provider I'm writing. The EF expecting a boolean while the ADO provider returns an Int16 so the EF raises an InvalidOperationException The specified cast from a materialized 'System.Int16' type to the 'System.Boolean' type is not valid. Is there a way to customize the materialization process of the entity framework to make it call a materialization process implemented by the provider? EDIT Partially found a solution... I can't

Debugging 'A dependent property in a ReferentialConstraint is mapped to a store-generated column.'

时间秒杀一切 提交于 2020-01-15 12:23:34
问题 I started to get this error after marking an ID column on an entity with DatabaseGeneratedOption.Identity (for some reason EF didn't know it was an identity column and was trying to insert a value on that column). I found this question: A dependent property in a ReferentialConstraint is mapped to a store-generated column. However, as far as I can tell, all of my relations are perfectly fine. I checked every single table, and triple checked the tables related to the one on which I added the

Debugging 'A dependent property in a ReferentialConstraint is mapped to a store-generated column.'

允我心安 提交于 2020-01-15 12:23:30
问题 I started to get this error after marking an ID column on an entity with DatabaseGeneratedOption.Identity (for some reason EF didn't know it was an identity column and was trying to insert a value on that column). I found this question: A dependent property in a ReferentialConstraint is mapped to a store-generated column. However, as far as I can tell, all of my relations are perfectly fine. I checked every single table, and triple checked the tables related to the one on which I added the

Exception while passing enum value to stored procedure using Entity Framework 6

↘锁芯ラ 提交于 2020-01-15 11:14:28
问题 I have an enum public enum Group { Services = 1, Dev = 2, Support = 3 } I am using it in a model public class Invoice { public int ID { get; set; } public DateTime MyDate { get; set; } public string Name { get; set; } public Group? Group { get; set; } } Now I am calling a stored procedure using the above model class: public ... method(Group grp) var Details = this.Context.Database.SqlQuery<Invoice>("spname @ID,@MyDate,@Name,@Group, ...... new SqlParameter("Group", grp), ).ToList(); Group is

c#, Is it possible to define databinding from sqlite database to c# object typesave?

旧巷老猫 提交于 2020-01-15 10:52:27
问题 I have the following class hirarchy: public class A { public string A_string; public int A_int; public double A_double; public B BInstance; } public class B { public string B_string; public int B_int; public double B_double; public C CInstance; } public class C { public string C_string; public int C_int; public double C_double; } and need a mapping to the following database values: +--------------+-----------+--------------+---------------------+-------------------+----------------------+----

c#, Is it possible to define databinding from sqlite database to c# object typesave?

倾然丶 夕夏残阳落幕 提交于 2020-01-15 10:51:22
问题 I have the following class hirarchy: public class A { public string A_string; public int A_int; public double A_double; public B BInstance; } public class B { public string B_string; public int B_int; public double B_double; public C CInstance; } public class C { public string C_string; public int C_int; public double C_double; } and need a mapping to the following database values: +--------------+-----------+--------------+---------------------+-------------------+----------------------+----

Entity Framework 6 Code First on SQL Server: Map “bool” to “numeric(1,0)” instead of “bit”

北城以北 提交于 2020-01-15 10:26:09
问题 Forward warning #0: upgrading to EF core is not an option in the near future. Forward warning #1: I can't change the column type to bit because this could potentially break legacy VB apps that employ the very same db I'm developing a new app for. Forward warning #2: I also can't employ the int property ==> hidden bool property approach because the very same model needs to work when targeting an Oracle database (in Oracle decimal(1,0) does indeed get mapped to bool without issues - I need to

Entity Framework 6 Code First on SQL Server: Map “bool” to “numeric(1,0)” instead of “bit”

此生再无相见时 提交于 2020-01-15 10:25:08
问题 Forward warning #0: upgrading to EF core is not an option in the near future. Forward warning #1: I can't change the column type to bit because this could potentially break legacy VB apps that employ the very same db I'm developing a new app for. Forward warning #2: I also can't employ the int property ==> hidden bool property approach because the very same model needs to work when targeting an Oracle database (in Oracle decimal(1,0) does indeed get mapped to bool without issues - I need to

JavaScriptSerializer().Serialize(Entity Framework object)

两盒软妹~` 提交于 2020-01-15 10:22:47
问题 May be, it is not so problematic for you. but i'm trying first time with json serialization. and also read other articles in stackowerflow. I have created Entity Framework data model. then by method get all data from object: private uqsEntities _db = new uqsEntities(); //get all data from table sysMainTableColumns where tableName=paramtableName public List<sysMainTableColumns> getDataAboutMainTable(string tableName) { return (from column in _db.sysMainTableColumns where column.TableName=

JavaScriptSerializer().Serialize(Entity Framework object)

我们两清 提交于 2020-01-15 10:22:34
问题 May be, it is not so problematic for you. but i'm trying first time with json serialization. and also read other articles in stackowerflow. I have created Entity Framework data model. then by method get all data from object: private uqsEntities _db = new uqsEntities(); //get all data from table sysMainTableColumns where tableName=paramtableName public List<sysMainTableColumns> getDataAboutMainTable(string tableName) { return (from column in _db.sysMainTableColumns where column.TableName=