M
M
Maria2018-09-13 12:52:06
ASP.NET
Maria, 2018-09-13 12:52:06

Why is the database not being created in Entity Framework (Code First)?

I create connection strings as indicated in the documentation, but for some reason, when I start the application, the database is not created

<connectionStrings>		
    <add name="ProductsContext" connectionString="Data Source=(LocalDb)\MSSQLLocalDB;Initial Catalog=OnlineStoreParser1;AttachDBFilename=|DataDirectory|\OnlineStoreParser1.mdf;Integrated Security=SSPI;" providerName="System.Data.SqlClient"/>
  </connectionStrings>

using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Web;

namespace OnlineStoreParser.Models
{
    public class ProductsContext : DbContext
    {
        public ProductsContext() : base("ProductsContext") { }

        public DbSet<Product> Products { get; set; }
        public DbSet<HistoryEntry> History { get; set; }
    }
}

What could be the problem? The only thing is that my database was created once, but I deleted it manually. And that's it .. after that it is not created. How to be now?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Peter, 2018-09-13
@Morpheus_God

In the context constructor, you did not specify an article
for you to review .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question