Hey Ismail. I had a complete mess yesterday. I dropped all those efforts to create a separate module.
I am now making sure that my custom code is under 1 folder in each of .Core and .Application.
The rest of things I will keep track of, so that when I upgrade my files and nuget packages, i know when to replace manually.
I don't think other than that it will work :(
Thanks
Hi, In doing an effort to modularize my app more, I'm making use of a blog module that has the path of: App/Main/views/blog/blog.cshtml and blog.js
Inside blog.js:
(function() {
angular.module('app').config([
'$stateProvider',
function ($stateProvider) {
$stateProvider
.state('blog', {
url: '#/blog',
templateUrl: '~/App/Main/views/blog/blog.cshtml',
menu: 'SampleBlog.AdminPage'
});
}
]);
angular.module('app').controller('app.views.blog', [
'$scope', 'abp.services.blog.post',
function ($scope, postService) {
var vm = this;
vm.posts = [];
postService.getPosts({
maxResultCount: 1000
}).success(function(result) {
vm.posts = result.items;
});
}
]);
})();
Also, the BlogNavigationProvider looks like this:
public class BlogNavigationProvider : NavigationProvider
{
public override void SetNavigation(INavigationProviderContext context)
{
context.Manager.MainMenu.Items.Add(
new MenuItemDefinition(
"SampleBlog.AdminPage",
new FixedLocalizableString("Blog"),
url: "/blog",
icon: "fa fa-list"
)
);
}
}
The menu "Blog" appears in the backend. But when I click on it, it says
Error: Could not resolve '/blog' from state 'host.tenants'
I marked both blog.cshtml and blog.js as Embedded resources.
What else should be done?
Thanks
Now, when I re-use Blog.EntityFramework in a sense I set SetInitializer(null) so that only 1 DbContext creates tables, the rest will just use the existing tables.
I then get this exception below.
So dealing with separate modules is full of exceptions and spending lots of hours to make this work.
Found more than one concrete type for given DbContext Type (Abp.Zero.EntityFramework.AbpZeroCommonDbContext`2[MainApp.Authorization.Roles.Role,MainApp.Authorization.Users.User]) define MultiTenancySideAttribute with Host. Found types: MainApp.EntityFramework.MainAppDbContext, MainApp.EntityFramework, Version=3.1.0.0, Culture=neutral, PublicKeyToken=null, MainApp.Blog.EntityFramework.MainAppBlogDbContext, MainApp.Blog.EntityFramework, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
Ok, I removed the folder Auth from the Blog.Core module and added a reference to the MainApp.Core so that both use the same User, Role, etc.
Now, when I run the application I get this exception. I went back to check the code for the blog module, there was an attribute on the Blog DbContext as follows:
[AutoRepositoryTypes(
typeof(ISampleBlogRepository<>),
typeof(ISampleBlogRepository<,>),
typeof(SampleBlogRepositoryBase<>),
typeof(SampleBlogRepositoryBase<,>)
)]
public class SampleBlogDbContext : AbpZeroDbContext<BlogTenant, BlogRole, BlogUser>
Maybe Framework has changed a lot since that blog module was created. But really, why is it that difficult to create a custom module and make the application moduler?
"Can't create component 'MainApp.Blog.Posts.PostAppService' as it has dependencies to be satisfied.
↵
↵'MainApp.Blog.Posts.PostAppService' is waiting for the following dependencies:
↵- Service 'MainApp.Blog.Domain.Repositories.ISampleBlogRepository`1[[MainApp.Blog.Posts.Post, MainApp.Blog.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]' which was not registered.
↵"
Hello,
I am trying to re-do the Blog Module created by <a class="postlink" href="https://github.com/hikalkan">https://github.com/hikalkan</a> and hosted on <a class="postlink" href="https://github.com/aspnetboilerplate/sample-blog-module">https://github.com/aspnetboilerplate/sample-blog-module</a>.
I added the .Core, .Application and .Web modules. For the EntityFramework, I decided to include the Posts, Categories and Comments entities as part of the main App Db Context, as I mighit have entities from one module to be shared by another module, so this way, all modules will be using same Dbcontext.
The problem is the Blog module defines its own BlogUser and BlogRole and the exception below shows that. How to work around this?
Also, if I include those tables in main DbContext, how would Blog module be able to access the DbContext?
I got lost a bit.
I do care a lot to have my modules separate so that I can upgrade main framework files with every new release you have to benefit from bug fixes and new features.
I appreciate your assistance. Thank
PM> Add-Migration "Added_Blog_Tables"
System.InvalidOperationException: The entity types 'BlogUser' and 'User' cannot share table 'AbpUsers' because they are not in the same type hierarchy or do not have a valid one to one foreign key relationship with matching primary keys between them.
at System.Data.Entity.ModelConfiguration.Configuration.Mapping.EntityMappingConfiguration.UpdateColumnNamesForTableSharing(DbDatabaseMapping databaseMapping, EntityType entityType, EntityType toTable, MappingFragment fragment)
at System.Data.Entity.ModelConfiguration.Configuration.Mapping.EntityMappingConfiguration.FindOrCreateTargetTable(DbDatabaseMapping databaseMapping, MappingFragment fragment, EntityType entityType, EntityType fromTable, Boolean& isTableSharing)
at System.Data.Entity.ModelConfiguration.Configuration.Mapping.EntityMappingConfiguration.Configure(DbDatabaseMapping databaseMapping, ICollection`1 entitySets, DbProviderManifest providerManifest, EntityType entityType, EntityTypeMapping& entityTypeMapping, Boolean isMappingAnyInheritedProperty, Int32 configurationIndex, Int32 configurationCount, IDictionary`2 commonAnnotations)
at System.Data.Entity.ModelConfiguration.Configuration.Types.EntityTypeConfiguration.ConfigureTablesAndConditions(EntityTypeMapping entityTypeMapping, DbDatabaseMapping databaseMapping, ICollection`1 entitySets, DbProviderManifest providerManifest)
at System.Data.Entity.ModelConfiguration.Configuration.ModelConfiguration.ConfigureEntityTypes(DbDatabaseMapping databaseMapping, ICollection`1 entitySets, DbProviderManifest providerManifest)
at System.Data.Entity.ModelConfiguration.Configuration.ModelConfiguration.Configure(DbDatabaseMapping databaseMapping, DbProviderManifest providerManifest)
at System.Data.Entity.DbModelBuilder.Build(DbProviderManifest providerManifest, DbProviderInfo providerInfo)
at System.Data.Entity.DbModelBuilder.Build(DbConnection providerConnection)
at System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext internalContext)
at System.Data.Entity.Internal.RetryLazy`2.GetValue(TInput input)
at System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
at System.Data.Entity.Internal.InternalContext.ForceOSpaceLoadingForKnownEntityTypes()
at System.Data.Entity.DbContext.System.Data.Entity.Infrastructure.IObjectContextAdapter.get_ObjectContext()
at Abp.EntityFramework.AbpDbContext.RegisterToChanges() in D:\Halil\Github\aspnetboilerplate\src\Abp.EntityFramework\EntityFramework\AbpDbContext.cs:line 141
at Abp.Zero.EntityFramework.AbpZeroDbContext`3..ctor(String nameOrConnectionString) in D:\Halil\Github\module-zero\src\Abp.Zero.EntityFramework\Zero\EntityFramework\AbpZeroDbContext.cs:line 66
at MainApp.EntityFramework.MainAppDbContext..ctor() in D:\Workspace\MainApp\app\MainApp.EntityFramework\EntityFramework\MainAppDbContext.cs:line 41
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Data.Entity.Infrastructure.DbContextInfo.CreateInstance()
at System.Data.Entity.Infrastructure.DbContextInfo..ctor(Type contextType, DbProviderInfo modelProviderInfo, AppConfig config, DbConnectionInfo connectionInfo, Func`1 resolver)
at System.Data.Entity.Migrations.DbMigrator..ctor(DbMigrationsConfiguration configuration, DbContext usersContext, DatabaseExistenceState existenceState, Boolean calledByCreateDatabase)
at System.Data.Entity.Migrations.DbMigrator..ctor(DbMigrationsConfiguration configuration)
at System.Data.Entity.Migrations.Design.MigrationScaffolder..ctor(DbMigrationsConfiguration migrationsConfiguration)
at System.Data.Entity.Migrations.Design.ToolingFacade.ScaffoldRunner.Run()
at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)
at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)
at System.Data.Entity.Migrations.Design.ToolingFacade.Run(BaseRunner runner)
at System.Data.Entity.Migrations.Design.ToolingFacade.Scaffold(String migrationName, String language, String rootNamespace, Boolean ignoreChanges)
at System.Data.Entity.Migrations.AddMigrationCommand.Execute(String name, Boolean force, Boolean ignoreChanges)
at System.Data.Entity.Migrations.AddMigrationCommand.<>c__DisplayClass2.<.ctor>b__0()
at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command)
Thanks I will check it out.
Yes. I created all those tenants as I was trying and I was infront of client :( and all failed.
any idea whats going on?
Hello,
Is there a guide on how to integrate Kendo UI CSS and JS files into an ASP.NET MVC / Angualr js 1.x to use their Grids and other controls instead of those that ship from metronic?
Thank you Bilal
Me too. I was so much overwhelmed. I am trying slowly to learn more about the framework by digging through the code etc.
My main concern now is to be able to upgrade whenever they release a new release.
Tomorrow, I will download a project 2 releases before. Create a new Solution Folder with .Core, .Application, .Web and .EntityFramework.
Then manage the references between all the modules and DependsOn.
Once all works out, I will try to replace all the framework files from the latest and try to run again. I believe I would need to run an Update-Database here in case there is anything changed in DB.
I will keep you posted :)
Thanks