Commit 6c89ad6c authored by Kirill's avatar Kirill

Merge branch 'sqliteef6' into develop

parents 0750ea4b 41fe87fc
...@@ -6,13 +6,4 @@ ...@@ -6,13 +6,4 @@
<startup> <startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" /> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup> </startup>
<entityFramework>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
<provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
<provider invariantName="System.Data.SQLite" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
</providers>
</entityFramework>
</configuration> </configuration>
\ No newline at end of file
using System;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Common; using System.Data.Common;
...@@ -39,7 +40,7 @@ namespace TourDataManager { ...@@ -39,7 +40,7 @@ namespace TourDataManager {
protected override void OnModelCreating(DbModelBuilder modelBuilder){ protected override void OnModelCreating(DbModelBuilder modelBuilder){
modelBuilder.Entity<Foo>(); //modelBuilder.Entity<Foo>();
var sqliteConnectionInitializer = new SqliteCreateDatabaseIfNotExists<MyDbContext>(modelBuilder); var sqliteConnectionInitializer = new SqliteCreateDatabaseIfNotExists<MyDbContext>(modelBuilder);
Database.SetInitializer(sqliteConnectionInitializer); Database.SetInitializer(sqliteConnectionInitializer);
} }
...@@ -56,7 +57,7 @@ namespace TourDataManager { ...@@ -56,7 +57,7 @@ namespace TourDataManager {
using (var sqLiteConnection = new System.Data.SQLite.SQLiteConnection("data source=mylovelybase.sqlite")){ using (var sqLiteConnection = new System.Data.SQLite.SQLiteConnection("data source=mylovelybase.sqlite")){
using (var db = new MyDbContext(sqLiteConnection,true)){ using (var db = new MyDbContext(sqLiteConnection,true)){
db.Foo.Add(new Foo{Id = 8, Data = "Yolo"}); db.Foo.Add(new Foo{Id = new Random().Next(0,1000), Data = "Yolo"});
db.SaveChanges(); db.SaveChanges();
//db.Set<Foo>() //db.Set<Foo>()
......
using System.Data.Entity;
using System.Data.Entity.Core.Common;
using System.Data.Entity.Infrastructure;
using System.Data.SQLite.EF6;
namespace TourDataManager {
//public class Ef6CodeConfig : DbConfiguration {
// protected internal Ef6CodeConfig(){
// SetProviderFactory("System.Data.SQLite.EF6", SQLiteProviderFactory.Instance);
// SetProviderServices("System.Data.SQLite", (DbProviderServices)SQLiteProviderFactory.Instance.GetService(typeof(DbProviderServices)));
// }
//}
}
\ No newline at end of file
namespace TourDataManager.Entities {
public class Estate {
/// Идентификатор объекта недвижимости
public long Id{ get; set; }
public string Title{ get; set; }
public int TourCount{ get; set; } //cnt_tours
public string Preview{ get; set; }
public string Created{ get; set; }
}
}
\ No newline at end of file
namespace TourDataManager.Entities {
public class Tour {
public long Id{ get; set; }
public string Title{ get; set; }
public string Preview{ get; set; }
public string Screen{ get; set; }
public int EstateId{ get; set; }
public string Created{ get; set; }
public string Updated{ get; set; }
public string Type{ get; set; }
/// Состояние тура
public int State{ get; set; }
}
}
\ No newline at end of file
...@@ -103,7 +103,8 @@ ...@@ -103,7 +103,8 @@
<Compile Include="CookieStorage.cs" /> <Compile Include="CookieStorage.cs" />
<Compile Include="Db.cs" /> <Compile Include="Db.cs" />
<Compile Include="Debug.cs" /> <Compile Include="Debug.cs" />
<Compile Include="EF6CodeConfig.cs" /> <Compile Include="Entities\Estate.cs" />
<Compile Include="Entities\Tour.cs" />
<Compile Include="IAuthenticator.cs" /> <Compile Include="IAuthenticator.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TourDataManager.cs" /> <Compile Include="TourDataManager.cs" />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment