Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class User {
- public int Id { get; set; }
- public string Email { get; set; }
- public string Password { get; set; }
- }
- class TestContext : DbContext {
- public DbSet<User> Users { get; set; }
- public TestContext() :base("TestModel"){
- //Create database always, even If exists
- Database.SetInitializer<TestContext>(new DropCreateDatabaseAlways<TestContext>());
- }
- }
- <connectionStrings>
- <add name="TestModel" connectionString="data source="C:UsersrootDocumentsVisual Studio 2015ProjectsdbTESTdbTESTbinDebugdatabase.db"" providerName="System.Data.SQLite.EF6" />
- </connectionStrings>
- using (var ctx = new TextContext()) {
- ctx.Database.Create();
- }
- An unhandled exception of type 'System.InvalidOperationException' occurred in EntityFramework.dll
- Additional information: Database 'main' cannot be created because it already exists.
Add Comment
Please, Sign In to add comment