c# - EF 6 with System.Data.SQlite SaveChanges() not working? -
So I have just started using System.Data.Sqlite with System Framework 6 (Nuget from the latest System. Data.Sqlite is downloaded, version 1.0.91.0) After some configuration and code, I found out that I can read from the database but no writing is working.
Here's my code:
using (var reference = new internal dbctext ()) {var demo = context.DemoEntities.Where (d = & gt; DID == 1) .FirstOrDefault (); Demo .name = "teststest"; Context.DemoEntities.Add (new demo {name = "test"}); Context.SaveChanges (); }
Actually after the SaveChanges, anything in the DB was not updated. Although I can read from DB, I can read manually with the data on the population via SQLIT Admin Tool.
Here is my DB schema: Table name: Demo field: ID - Integer primary key Automatic radiation field: Name - VARCHAR (256)
Here are my classes
Public category internal DBcintex: DBcinTex {public DBSET & lt; Demo & gt; {Receive; demointees; Set; } Public Internal DBContext () {// Close the migration, (no code is not the first DB) database. SetInitializer & lt; Internal DBcintex & gt; (Empty); } Secure Override Zero OnModelCreating (DbModelBuilder ModelBuilder) {// database table name module does not do the kaleidoscope Builder.Conventions.Remove & lt; PluralizingTableNameConvention & gt; (); } {Table ("Demo")} Public Category Demo {Public Long ID (Receive; Set;} Public String Name {get} Set;}}
App.config
& lt; xml version = "1.0" encoding = "UTF-8"? & Gt; Configuration> gt; & lt; configSections & gt; & lt; section group name = "Normal"> gt; name of section = "logging" type = "normal logging .config configuration section, common.living" /> & lt; / sectionGroup & gt; & lt ;! - entity framework configuration Know more about For an error, go to http://go.microsoft.com/fwlink/?LinkID=237468 -> Go to & gt; section name = "Antenna framework" type = "system.data.tt.innal config.config file. AntiTeam Framework Description, Entity Framework, Version = 6.0.0.0, Culture = Neutral, Public Key Token = B77A5C 561934A 90 "Requirements =" false "/> & lt; / configSections & gt; & lt; mango & Gt; & lt; logging & gt; factory factory adapter type = "mr.logging.log4net.log4netloggerfactor adapter, common.logging.lo 4 Net "& gt; & Lt; Arg key = "configType" value = "file-watch" /> & Lt; Arg key = "configfile" value = "log4net.config" /> & Lt; / FactoryAdapter & gt; & Lt; / Logging & gt; & Lt; / Mangoes & gt; & Lt; Order & gt; & Lt; Assembly binding xmlns = "karash: schema-microsoft-com: asm.v1" & gt; & Lt; DependentAssembly & gt; & Lt; Assembly Identification Name = "General. Logging" publicKeyToken = "af08829b84f0328e" culture = "neutral" /> & Lt; Compulsive Redirect Old Version = "0.0.0.0-2.0.0.0" Newverson = "2.0.0.0" /> & Lt; / DependentAssembly & gt; & Lt; DependentAssembly & gt; & Lt; Assembly ID name "log4net" publicKeyToken = "669e0ddf0bb1aa2a" culture = "neutral" /> Lt; / dependentAssembly & gt; & lt; / assemblyBinding & gt; & lt; / sequence & gt; entityFramework & gt; defaultConnectionFactory type = "System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework" & Gt; & lt; parameters & gt; & lt; parameter value = "v11.0" /> gt; & lt; providers & gt; & lt; Provider invarianatName = "System.Data.SqlClient" type = "System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /> & gt; & lt; Provider invariantN Ame = "System.Data.SQLite.EF6" type = "System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" /> & lt; / providers & gt; & lt; / entityFramework & Gt; & lt; ConnectionStrings & gt; & lt; add name = "InternalDbContext" connectionString = "data source =. \ Testdb.sqlite "Provider Name =" System.Data.SQLite.EF6 "/> & lt; / ConnectionStrings & gt; SystemData & gt; & lt; DbProviderFactories & gt; & lt; Remove invariant = "System.Data.SQLite.EF6" /> & lt; / DbProviderFactories & gt; & lt; /system.data> & lt; / Configuration & gt;
Div class = "post-text" itemprop = "text"> Yours There should be a copy of your testdb.sqlite DB in the / bin / debug / folder. It should be altered.
Comments
Post a Comment