entity-framework

How to map a column name with spaces in it to a POCO property?

女生的网名这么多〃 提交于 2021-01-18 05:47:05
问题 I am working on database table which has a column name with a space in it, for example "Level Description". I cannot change the column name. Now I have an Entity Framework model class for this table and the compiler is complaining about this property, because property names can't contain spaces! How can I define the column with space in my class? [Table("StudyLevel")] public class StudyLevelModel { [Key] public byte StudyLevelID { get; set; } // How to map this to the column "Level

How to MAP select stored procedure in Entity Framework 6 code-first approach?

懵懂的女人 提交于 2021-01-18 04:47:08
问题 For example when we write protected override void OnModelCreating(DbModelBuilder modelBuilder) { modelBuilder.Entity<tblError>().MapToStoredProcedures(); } Then it will create 3 stored procedures in the database with the names of tblError_Delete , tblError_Insert , tblError_Update My question is about tblError_Select : how to map a stored procedure that is used to execute select queries? I want EF to be generate tblError_Select along with preceding 3 stored procedures. I want to do CRUD

Mysql Entity framework exception

蓝咒 提交于 2021-01-07 03:10:47
问题 .Net Framework : 4.7.2 MySql server installed: 8.0.12 MySql connector/Net : 8.0.12 Entity Framework: 6.2.0 MySql.Data : 8.0.12 MySql.Data.EntityFramework: 8.0.12 Web.config configuration <system.data> <DbProviderFactories> <remove invariant="MySql.Data.MySqlClient" /> <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.EntityFramework, Version=8.0.12.0, Culture

.net 5.0 EF migrations adding stored proc models to ModelSnapshot

℡╲_俬逩灬. 提交于 2021-01-07 02:41:09
问题 I recently upgraded to .net 5.0 and I use entity framework. I edited a database model by adding an extra field and ran my normal script in powershell dotnet ef migrations add mig_name Since the C# upgrade though the upgrade script is trying to add all my Keyless models that I use for Stored Procs to the ModelSnapshot file. And what that means is that it tries to then drop these tables from the database even though they don't exist. protected override void Up(MigrationBuilder migrationBuilder)

.net 5.0 EF migrations adding stored proc models to ModelSnapshot

久未见 提交于 2021-01-07 02:40:53
问题 I recently upgraded to .net 5.0 and I use entity framework. I edited a database model by adding an extra field and ran my normal script in powershell dotnet ef migrations add mig_name Since the C# upgrade though the upgrade script is trying to add all my Keyless models that I use for Stored Procs to the ModelSnapshot file. And what that means is that it tries to then drop these tables from the database even though they don't exist. protected override void Up(MigrationBuilder migrationBuilder)

Remove a duplicate Context.vb files from Entity Framework

对着背影说爱祢 提交于 2021-01-05 10:45:33
问题 I'm having a bit of an issue with EF6 in VS2013. I had to modify the connection string for the database-first model in a Web Application project so I followed the advice in the best answer for How should I edit an Entity Framework connection string? and deleted it from my Web.Config file. At first it seemed to work fine, I deleted the connection string then from the Entity Designer I ran "Update Model from Database", re-created the connection string, but then my build failed with multiple

Remove a duplicate Context.vb files from Entity Framework

喜欢而已 提交于 2021-01-05 10:38:34
问题 I'm having a bit of an issue with EF6 in VS2013. I had to modify the connection string for the database-first model in a Web Application project so I followed the advice in the best answer for How should I edit an Entity Framework connection string? and deleted it from my Web.Config file. At first it seemed to work fine, I deleted the connection string then from the Entity Designer I ran "Update Model from Database", re-created the connection string, but then my build failed with multiple

VS 2019 and MySQL Entity Framework duplicate database name

吃可爱长大的小学妹 提交于 2021-01-05 08:55:52
问题 I added Entity Framework to my project but I call the toList() method and I'm getting an error: okuldbEntities ent = new okuldbEntities(); private void Form1_Load(object sender, EventArgs e) { dataGridView1.DataSource = ent.ogrenciler.ToList(); } and this is the error: This exception was originally thrown at this call stack: [External Code] Inner Exception 1: MySqlException: Table ' okuldb.okuldb .ogrenciler' doesn't exist okuldb is my database name and I didn't find why it added it twice. I

Mapping foreign key to non primary surrogate key column in EF code first

余生长醉 提交于 2021-01-02 06:16:12
问题 public class A { [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public virtual int Aid { get; set; } public virtual ICollection<B> B { get; set; } } public class B { [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public virtual int Bid { get; set; } [Key] [Column(Order = 0)] [Required] Public virtual string BName {get ; set} [Key] [Column(Order = 1)] [Required] public virtual int Aid { get; set; } [ForeignKey("Aid")] public virtual A A { get; set; } public virtual ICollection<C>

What does DbConnection.EnlistTransaction do? [closed]

那年仲夏 提交于 2021-01-02 05:21:42
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 5 months ago . Improve this question What does DbConnection.EnlistTransaction do? 回答1: DbConnection.EnlistTransaction allows: Joining the connection to a System.Transactions.Transaction. It has some constraints: If the connection is already participating in a "local" transaction (System.Data