Guest User

Untitled

a guest
Oct 17th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. class User {
  2. public int Id { get; set; }
  3. public string Email { get; set; }
  4. public string Password { get; set; }
  5. }
  6.  
  7. class TestContext : DbContext {
  8. public DbSet<User> Users { get; set; }
  9.  
  10. public TestContext() :base("TestModel"){
  11. //Create database always, even If exists
  12. Database.SetInitializer<TestContext>(new DropCreateDatabaseAlways<TestContext>());
  13. }
  14. }
  15.  
  16. <connectionStrings>
  17. <add name="TestModel" connectionString="data source="C:UsersrootDocumentsVisual Studio 2015ProjectsdbTESTdbTESTbinDebugdatabase.db"" providerName="System.Data.SQLite.EF6" />
  18. </connectionStrings>
  19.  
  20. using (var ctx = new TextContext()) {
  21. ctx.Database.Create();
  22. }
  23.  
  24. An unhandled exception of type 'System.InvalidOperationException' occurred in EntityFramework.dll
  25.  
  26. Additional information: Database 'main' cannot be created because it already exists.
Add Comment
Please, Sign In to add comment