EDIT: modelBuilder.Entity<VwAlacaklar>().ToTable(nameof(VwAlacaklar), t => t.ExcludeFromMigrations());
solved my problem.
I have a production in which I created a database in a new membership. There are 20 database view dbset classes in my partial dbcontext;
public partial class DbModel
{
public virtual DbSet<ViewType1> ViewType1{ get; set; }
public virtual DbSet<ViewType2> ViewType2{ get; set; }
...
partial void OnModelCreatingPartial(ModelBuilder modelBuilder)
{
modelBuilder.Entity<ViewType1>(_ =>
{
_.HasNoKey();
});
modelBuilder.Entity<ViewType2>(_ =>
{
_.HasNoKey();
});
}
}
When I create the database with Context.Database.EnsureCreated();
, Along with the tables, the views are also created like a table.
How do I prevent views from being created in the database? They just need to be in the project as code.